Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFromDir ¶
ParseFromDir parses the mllint config from the given project directory. If an `.mllint.yml` file is present, then this will be used, otherwise, if a `pyproject.toml` file is present, then this will be used, otherwise, the default config is returned. The returned FileType will be either config.TypeYAML, config.TypeTOML, or config.TypeDefault.
Types ¶
type CodeQualityConfig ¶
type CodeQualityConfig struct {
// Defines all code linters to use in the Code Quality category
Linters []string `yaml:"linters" toml:"linters"`
}
CodeQualityConfig contains the configuration for the CQ linters used in the Code Quality category
type Config ¶
type Config struct {
Rules RuleConfig `yaml:"rules" toml:"rules"`
Git GitConfig `yaml:"git" toml:"git"`
CodeQuality CodeQualityConfig `yaml:"code-quality" toml:"code-quality"`
Testing TestingConfig `yaml:"testing" toml:"testing"`
}
Config describes the structure of an `.mllint.yml` file
func ParseTOML ¶
ParseYAML parses the TOML config from the given reader (tip: *os.File implements io.Reader)
type CustomRule ¶ added in v0.11.0
type CustomRule struct {
Name string `yaml:"name" toml:"name"`
Slug string `yaml:"slug" toml:"slug"`
Details string `yaml:"details" toml:"details"`
Weight float64 `yaml:"weight" toml:"weight"`
Run string `yaml:"run" toml:"run"`
}
CustomRule contains the configuration for custom rules
type GitConfig ¶
type GitConfig struct {
// Maximum size of files in bytes tolerated by the 'git-no-big-files' linter
// Default is 10 MB
MaxFileSize uint64 `yaml:"maxFileSize" toml:"maxFileSize"`
}
GitConfig contains the configuration for the Git linters.
type RuleConfig ¶
type RuleConfig struct {
Disabled []string `yaml:"disabled" toml:"disabled"`
Custom []CustomRule `yaml:"custom" toml:"custom"`
}
RuleConfig contains info about which rules are enabled / disabled.
type TestCoverage ¶
type TestCoverage struct {
// Filename of the project's test coverage report, either absolute or relative to the project's root.
// Expects a Cobertura-compatible XML file, which can be generated after `coverage run -m pytest --junitxml=tests-report.xml`
// with `coverage xml -o tests-coverage.xml`, or using the `pytest-cov` plugin.
Report string `yaml:"report" toml:"report"`
// Specifies the target amount of line / branch / whatever coverage that the user wants want to have in the project
// Only line coverage is implemented so far.
Targets TestCoverageTargets `yaml:"targets" toml:"targets"`
}
type TestCoverageTargets ¶
type TestCoverageTargets struct {
// Target amount of overall line coverage to achieve in tests.
Line float64 `yaml:"line" toml:"line"`
}
type TestingConfig ¶
type TestingConfig struct {
// Filename of the project's test execution report, either absolute or relative to the project's root.
// Expects a JUnit XML file, which when using `pytest` can be generated with `pytest --junitxml=tests-report.xml`
Report string `yaml:"report" toml:"report"`
// Settings about how many tests there should be in a project.
Targets TestingTargets `yaml:"targets" toml:"targets"`
// Settings about the rules for checking project test coverage.
Coverage TestCoverage `yaml:"coverage" toml:"coverage"`
}
TestingConfig contains the configuration for the rules in the Testing category.
type TestingTargets ¶
type TestingTargets struct {
// Minimum amount of test files to have in a project. Absolute number. Defaults to 1.
Minimum uint64 `yaml:"minimum" toml:"minimum"`
// Ratio of test files to have in a project, i.e. number of test files per other Python file.
// Defaults to 1 part tests to 4 parts non-tests
Ratio TestingTargetsRatio `yaml:"ratio" toml:"ratio"`
}