Shared Analysis Configuration
This document outlines the capabilities available in Qlty CLI and Qlty Cloud to support sharing of analysis configuration across multiple repositories within a single workspace.
Goals
- Simplify the set up and maintenance of static analysis configuration across a large number of GitHub repositories
- Provide partial or full standardization of static analysis configuration for the organization
Custom Sources
The primary method of sharing analysis configuration across multiple repositories is through defining a custom Source. A Source is a Git repository that stores version controlled static analysis configuration settings which can be re-used by other repositories.
Custom Sources were designed to replace the delegated configuration feature of Code Climate Quality while adding new capabilities.
Features of Custom Sources
- Create and share new, custom Plugin Definitions
- Example: Define a custom plugin to check that all
package.json
files specify an acceptablelicense
value
- Example: Define a custom plugin to check that all
- Customize out-of-the-box Plugin Definitions
- Example: **Override the default definition of the Prettier auto-formatter to avoid rewriting
*.mdx
files
- Example: **Override the default definition of the Prettier auto-formatter to avoid rewriting
- Share maintainability analysis settings
- Example: Increase the complexity threshold for the “High Function Complexity” code smell
- Example: Add an code filter to exclude common boilerplate from an internally developed framework from duplication detection
- Share file path exclusions
- Example: Exclude all files matching
**/our_generator/**
- Example: Exclude all files matching
- Share issue triage rules
- Example: Downgrade the
level
of issues found by Trivy in thesandbox/**
folder tolow
- Example: Downgrade the
- Automatically enable plugins
- Example: Always run the Shellcheck for any shell scripts in all repositories
- Share linter configuration files
- Example: Provide a base
rubocop.yml
configuration that can be extended for each project
- Example: Provide a base
Advantages of Custom Sources
- Settings provided by the Source can be further customized with the Project’s
qlty.toml
configuration file (layered configuration) - Sources can be declared as pinned (with Git tags) or floating to a branch
- Custom sources work on Qlty CLI and Qlty Cloud
Example
To use a Custom Source, each repository would declare it from the .qlty/qlty.toml
file:
The custom Source is a regular Git repository which follows a conventional structure:
- A
source.toml
file at the root of the repository can provide setings - Plugins can be defined or modified in files matching the patterns
plugins/linters/*/plugin.toml
Configuration Merging
Notably, Qlty uses the same TOML configuration syntax in every configuration file. This allows for taking advantage of the same configuration options — from plugin declaration settings to tuning maintainability smells — in any *.toml
file read by Qlty.
Configuration is applied in the following order from lowest precedence to highest precedence:
plugin.toml
files in Sourcessource.toml
file at the root of Sourcesqlty.toml
in the project
As the final, merged configuration is assembled, the last setting wins.
The full, merged configuration can be viewed as YAML by running qlty config show
.
Private, custom sources
Custom sources can now be private repos, provided they are in the same GitHub Org and the user has installed the new Qlty GitHub App.