2023-08-16 14:46:20 +00:00
# linters
2023-07-18 08:16:27 +00:00
## Overview
2023-08-16 14:46:20 +00:00
`linters` is a project that enables the integration of custom linting rules into the [golangci-lint ](https://github.com/golangci/golangci-lint ) framework.
2023-07-18 08:16:27 +00:00
2023-08-07 14:36:41 +00:00
## Usage
2023-08-16 14:46:20 +00:00
Add to .golangci.yml
2023-08-07 14:36:41 +00:00
```yml
linters-settings:
custom:
2023-08-16 14:46:20 +00:00
truecloudlab-linters:
2023-08-07 14:36:41 +00:00
path: < Path to the directory with libraries >
original-url: git.frostfs.info/TrueCloudLab/linters
linters:
enable:
2023-08-16 14:46:20 +00:00
truecloudlab-linters
2023-08-07 14:36:41 +00:00
```
## Installation
```bash
git clone git.frostfs.info/TrueCloudLab/linters
cd linters
make lib OUT_DIR=< Path to the directory with libraries >
```
2023-07-18 08:16:27 +00:00
## Available linters
2023-08-16 14:46:20 +00:00
| 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 ). |
2023-08-01 11:39:49 +00:00
## Linters Configuration
2023-07-18 08:16:27 +00:00
2023-08-07 14:36:41 +00:00
Settings via a configuration file are available if golangci-lint >= 1.5.4 is used
2023-08-16 14:46:20 +00:00
### noliteral
2023-08-01 11:39:49 +00:00
2023-08-07 14:36:41 +00:00
##### File Configuration
2023-08-01 11:39:49 +00:00
```yml
linters-settings:
custom:
2023-08-16 14:46:20 +00:00
truecloudlab-linters:
2023-08-04 11:26:40 +00:00
path: .bin/external_linters.so
2023-08-16 14:46:20 +00:00
original-url: git.frostfs.info/TrueCloudLab/linters.git
2023-08-04 11:26:40 +00:00
settings:
2023-08-16 14:46:20 +00:00
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
2023-07-18 08:16:27 +00:00
```
2023-08-16 14:46:20 +00:00
### useStrconv
2023-08-04 11:26:40 +00:00
2023-08-16 14:46:20 +00:00
##### 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
```