linters/README.md
Alexander Chuprov 1c1b1596a8
All checks were successful
Tests and linters / Tests (pull_request) Successful in 1m34s
Tests and linters / Build lib (pull_request) Successful in 2m43s
Tests and linters / Staticcheck (pull_request) Successful in 5m4s
Tests and linters / Lint (pull_request) Successful in 3m16s
[#4] linters: add disable-packages option
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2023-08-07 17:36:41 +03:00

71 lines
2.3 KiB
Markdown

# linters
## Overview
`linters` is a project that enables the integration of custom linting rules into the [golangci-lint](https://github.com/golangci/golangci-lint) framework.
## Usage
Add to .golangci.yml
```yml
linters-settings:
custom:
custom-linters:
path: <Path to the directory with libraries>
original-url: git.frostfs.info/TrueCloudLab/linters
linters:
enable:
custom-linters
```
## Installation
```bash
git clone git.frostfs.info/TrueCloudLab/linters
cd linters
make lib OUT_DIR=<Path to the directory with libraries>
```
## Available linters
| Name | Description |
| ----------------------- | --------------------------------------------------------------------------- |
| [noliteral](#noliteral) | The tool prohibits the use of literal string arguments in logging functions |
## Linters Configuration
Settings via a configuration file are available if golangci-lint >= 1.5.4 is used
### noliteral
##### File Configuration
```yml
linters-settings:
custom:
noliteral:
path: .bin/external_linters.so
original-url: git.frostfs.info/TrueCloudLab/linters.git
settings:
target-methods: ["reportFlushError", "reportError"] # optional. Enabled by default "Debug", "Info", "Warn", "Error"
disable-packages: ["pkg1", "pkg2"] # List of packages for which the check should be disabled.
constants-package: "git.frostfs.info/rep/logs" # if not set, then the check is disabled
```
##### ENV Configuration
| Variable | Description |
| ----------------------------- | ------------------------------------------------------- |
| `NOLITERAL_TARGET_METHODS` | List of methods to analyze |
| `NOLITERAL_DISABLE_PACKAGES` | List of packages for which the check should be disabled |
| `NOLITERAL_CONSTANTS_PACKAGE` | Path to the package with constants |
**Note:** You may need to clear the golangci-lint cache when configuring through ENV. More details can be found [here](https://golangci-lint.run/usage/configuration/#cache).