Skip to content

revive

GitHub stars sarif GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

revive documentation

revive - GitHub

Configuration in MegaLinter

Variable Description Default value
GO_REVIVE_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
GO_REVIVE_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
GO_REVIVE_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
GO_REVIVE_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
GO_REVIVE_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
list_of_files
GO_REVIVE_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".go"]
GO_REVIVE_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
GO_REVIVE_PRE_COMMANDS List of bash commands to run before the linter None
GO_REVIVE_POST_COMMANDS List of bash commands to run after the linter None
GO_REVIVE_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling GO_REVIVE and its pre/post commands None
GO_REVIVE_CONFIG_FILE revive configuration file nameUse LINTER_DEFAULT to let the linter find it revive.toml
GO_REVIVE_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
GO_REVIVE_DISABLE_ERRORS Run linter but consider errors as warnings false
GO_REVIVE_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
GO_REVIVE_CLI_EXECUTABLE Override CLI executable ['revive']

IDE Integration

Use revive in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Atom linter-revive Visit Web Site
vim ale Visit Web Site
Visual Studio Code vscode.Go Install in VSCode

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 121 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 85 Docker Image Size (tag) Docker Pulls
go Optimized for GO based projects 53 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .go

How the linting is performed

  • revive is called once with the list of files as arguments (list_of_files CLI lint mode)

Example calls

revive myfile.go
revive -config myfile.go

Help content


 _ __ _____   _(_)__  _____
| '__/ _ \ \ / / \ \ / / _ \
| | |  __/\ V /| |\ V /  __/
|_|  \___| \_/ |_| \_/ \___|

Example:
  revive -config c.toml -formatter friendly -exclude a.go -exclude b.go ./...

Usage of revive:
  -config string
      path to the configuration TOML file, defaults to $HOME/revive.toml, if present (i.e. -config myconf.toml)
  -exclude value
      list of globs which specify files to be excluded (i.e. -exclude foo/...)
  -formatter string
      formatter to be used for the output (i.e. -formatter stylish)
  -max_open_files int
      maximum number of open files at the same time
  -set_exit_status
      set exit status to 1 if any issues are found, overwrites errorCode and warningCode in config
  -version
      get revive version

Installation on mega-linter Docker image

  • Dockerfile commands :
FROM golang:1-alpine as revive
## The golang image used as a builder is a temporary workaround 
## for the released revive binaries not returning version numbers (devel). 
## The install command should then be what is commented in the go.megalinter-descriptor.yml
RUN GOBIN=/usr/bin go install github.com/mgechev/revive@latest

COPY --link --from=revive /usr/bin/revive /usr/bin/revive