gomultilinter

command module
v0.0.0-...-27f9dfe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2018 License: MIT Imports: 9 Imported by: 0

README

GoMultiLinter

Software License Travis Go Report Card


Run Go lint tools via a plugin api. Parse AST once, lint it by all the linters.

Since Plugins are used under the hood gomultilinter currently only supports linux and macOS.

Quickstart

Installation

go get from HEAD: go get -u github.com/liut0/gomultilinter

Ensure the linter's are built with the excact same gomultilinter source as the gomultilinter binary.

Editor integration

  • Intellij: Use the filewatchers with the gomultilinter template and override the settings below:
    • Program: gomultilinter
    • Arguments: $FilePath$
    • Working directory: $FileDir$

Configuration

gomultilinter is configured via a yaml config file. Either the name of the configuration file has to be .gomultilinter.yml and it must be placed in the working directory or any parent directory or the location of the config file can be passed by the cli flag: -config=<file>. The format of this file is determined by the Config struct in config.go.

Example configuration file

exclude:
  tests: true
  names:
    - '_mock\\.go'
  categories:
    - 'comments'

linter:
  - package: 'github.com/liut0/gomultilinter-golint/gomultilinter'
    config:
      - max_cyclo: 10
  - plugin_path: '~/myGoMultilinterPlugin.so'
    config:
      - foo: 'bar'

Comment directives

gomultilinter supports suppression of linter messages via comment directives. The form of the directive is:

// nolint[: <linter>[, <linter>, ...]]

Linters

Available Linters

Currently the available linters are forks which implement the required interfaces with preferably minimal (but sometimes dirty, for easier merging) changes to the main repo. Maybe someday the maintainers of the linters will implement the interface in the main repository and the forks are not needed anymore. More linters will be added...

Custom Linters

Implementation

  • Implement the interfaces described in api/linter.go.
  • In a package named main hold a variable called LinterFactory of the type github.com/liut0/api/linter/LinterFactory.

The custom linter can be added to gomultilinter in two ways:

  • via the Package configuration directive of the config file (the package gets built by gomultilinter with buildmode=plugin)
  • via the PluginPath configuration directive of the config file (path to the prebuilt .so plugin file which gets picked up by gomultilinter)

Linter Vendoring

Linter packages get resolved from the working directory the same way go does. If a linter pkg exists in the vendor dir it's preferred. Therefore you can vendor the linter's how you would vendor any other package.

Docker build

Example of a docker build configuration

...

[RESTORE DEPENDENCIES]

RUN go get -v -u github.com/liut0/gomultilinter
COPY .gomultilinter.yml .
RUN gomultilinter -v -u -install-only

[COPY SOURCES]

RUN gometalinter -v

...

Exit status

Value Meaning
0 Succeed :)
1 An underlying error occurred
2 Issues occurred. Unless no-exit-status cli flag is set.

Feedback

Feedback is greatly appreciated. If you have any questions, please don't hesitate to create a issue.

inspired by gometalinter

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package api provides the plugin api to be implemented by linters and consumed by gomultilinter
Package api provides the plugin api to be implemented by linters and consumed by gomultilinter
Package config manages the configuration of gomultilinter
Package config manages the configuration of gomultilinter
internal
checker
Package checker can load files/packages and run linters on them
Package checker can load files/packages and run linters on them
checker/filter
Package filter provides filters to filter out excluded issues
Package filter provides filters to filter out excluded issues
checker/issue
Package issue provides models/helpers to the internal representation of issues
Package issue provides models/helpers to the internal representation of issues
files
Package files contains utils to work with files
Package files contains utils to work with files
loader
Package loader downloads, builds, installs and loads linter plugins
Package loader downloads, builds, installs and loads linter plugins
log
Package log contains helper for logrus
Package log contains helper for logrus
regex
Package regex utils to process regular expressions
Package regex utils to process regular expressions
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL