Usage#

When using glob-linters as a command line tool, you can use both command line options and configuration file to control the parameters for linting.

Command options#

Note

The command line options will be overwritten by configuration file . All given arguments will ignored if you use configuration file.

You can use glob_linters as a command line tool if you want to lint your codes or test your GitHub action workflow in local terminals.

-d [TARGET_DIR], --target-dir [TARGET_DIR]#

Specify the directory to be scanned for files to be linted.

Default: ., the current working directory when glob_linters is called.

Keyword in configuration file: target_dir.

-s [TARGET_SUFFIX ...], --file-suffix [TARGET_SUFFIX ...]#

Extensions of files to be linted, e.g., .cpp, .py, and can be given more than one, separated by comma or space. For example, --file-suffix .cpp .py

Default: all supported language extensions.

Keyword in configuration file: target_suffix.

-g, --enable-debug#

Enable debug mode. Debugging information will be outputed.

Default: disabled.

Keyword in configuration file: debug.

-c [CONFIGS ...], --configs [CONFIGS ...]#

Set configuration, use key=value format and separate multiple pairs by comma or space.

Default: None, i.e., use default values for all settings.

Keyword in configuration file: different key for different setting variables. See executable settings.

-C [CONFIG_FILE], --config-file [CONFIG_FILE]#

glob_linters configuration file (glob-linters.ini) path.

Default: .github/glob-linters.ini.

No keyword for this in configuration file.

Examples#

By issuing glob_linters in a directory like following:

$ glob_linters

without any options, glob_linters will recursively scan the directory to find files with all supported extensions using all default linters.

To change the target directory to src/ and only lint .py files, add options:

$ glob_linters --target-dir src --target-suffix .py

and if you also want to diasble flake8 and mypy linters with debugging information, do this:

$ glob_linters --target-dir src --target-suffix .py --configs .py.disable_linters=flake8,mypy

Configuration file#

The configuration file format follows configparse structure. The configuration file is generally used in GitHub actions. You can also use it to test your workflow in local terminals.

[target]#

target_dir = <TARGET_DIR>

Work as the same with glob_linters --target-dir.

target_suffix = <TARGET_SUFFIX ...>

Work as the same with glob_linters --file-suffix.

[excutable]#

Note

The configuration file for each linter will overwrite the corresponding .options.

cpplint = <exec>

Specify the executable path of cpplint. Can simply be cpplint = cpplint if it is included in PATH.

Default: cpplint.

cpplint.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g.,

cpplint.options = --filter=-whitespace,+whitespace/braces --root=..

Default configuration file location: .github/linter-configs/CPPLINT.cfg.

clang_format = <exec>

Specify the executable path of clang-format. Can simply be clang_format = clang-format if it is included in PATH.

clang_format.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g,

clang_format.options = --Werror --style=google

Default configuration file location: .github/linter-configs/.clang-format.

pylint = <exec>

Specify the executable path of pylint. Can simply be pylint = pylint if it is included in PATH.

pylint.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g,

pylint.options = --output-format=parseable

Default configuration file location: .github/linter-configs/.pylintrc.

flake8 = <exec>

Specify the executable path of flake8. Can simply be flake8 = flake8 if it is included in PATH.

flake8.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g.,

flake8.options = --max-line-length 88

Default configuration file location: .github/linter-configs/.flake8.

black = <exec>

Specify the executable path of black. Can simply be black = black if it is included in PATH.

black.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g.,

black.options = --diff --check

Default configuration file location: .github/linter-configs/.black.

isort = <exec>

Specify the executable path of isort. Can simply be isort = isort if it is included in PATH.

isort.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g.,

isort.options = --line-length 88 --color

Default configuration file location: .github/linter-configs/.isort.cfg.

mypy = <exec>

Specify the executable path of mypy. Can simply be mypy = mypy if it is included in PATH.

mypy.options = <...>

Specify the options that will passed to the executable. Format is the same as given in command line, e.g.,

mypy.options = --cache-dir .

Default configuration file location: .github/linter-configs/.mypy.ini.

[env]#

debug = <True | False>

Set glob_linters to debugging mode.

Default: False.

.cpp.linters = <...>

Specify linters used for .cpp files.

Default: .cpp.linters = cpplint clang_format.

.cpp.disable_linters = <...>

Disable linters used for .cpp files. Should be a list from the default linters with the same format as .cpp.linters.

.py.linters = <...>

Specify linters used for .py files.

Default: .py.linters = pylint.

.py.disable_linters = <...>

Disable linters used for .py files. Should be a list from the default linters with the same format as .py.linters.

Example#

A direct example is given as:

[target]
target_dir = .
target_suffix = .py

[executable]
pylint = pylint
black = black
isort = isort

[env]
debug = True
.py.disable_linters = flake8 mypy

The above example will only lint .py files in the current working directory with only pylint, black and isort linters as well as debugging mode enabled.

Linter configurations#

Configuration files for linters are given in LINTER_CONFIGS of GitHub repository as templates. You can modify them as you need.

Note

If you use glob_linters in GitHub action, please place configurations in .github/linter-configs/ and do NOT change the name of the configuration files.