forked from TrueCloudLab/linters
76 lines
2.5 KiB
Markdown
76 lines
2.5 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:
|
|
truecloudlab-linters:
|
|
path: <Path to the directory with libraries>
|
|
original-url: git.frostfs.info/TrueCloudLab/linters
|
|
|
|
|
|
linters:
|
|
enable:
|
|
truecloudlab-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. |
|
|
| [useStrconv](#useStrconv) | The `useStrconv` linter recommends the utilization of `strconv` over `fmt` when performing string conversions of primitive data types. Detailed guidelines can be found in the [official Uber Go Style Guide](https://github.com/uber-go/guide/blob/master/style.md#prefer-strconv-over-fmt). |
|
|
|
|
|
|
## Linters Configuration
|
|
|
|
Settings via a configuration file are available if golangci-lint >= 1.5.4 is used
|
|
|
|
### noliteral
|
|
|
|
##### File Configuration
|
|
|
|
```yml
|
|
linters-settings:
|
|
custom:
|
|
truecloudlab-linters:
|
|
path: .bin/external_linters.so
|
|
original-url: git.frostfs.info/TrueCloudLab/linters.git
|
|
settings:
|
|
noliteral:
|
|
enable: true # optional
|
|
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
|
|
```
|
|
|
|
### useStrconv
|
|
|
|
##### File Configuration
|
|
```yml
|
|
linters-settings:
|
|
custom:
|
|
truecloudlab-linters:
|
|
path: .bin/external_linters.so
|
|
original-url: git.frostfs.info/TrueCloudLab/linters.git
|
|
settings:
|
|
useStrconv: # optional
|
|
enable: true
|
|
```
|