mirror of
https://github.com/mgechev/revive.git
synced 2025-01-08 03:13:27 +02:00
Rename formatter
This commit is contained in:
parent
90b2213300
commit
b8e1c67e9c
10
README.md
10
README.md
@ -30,7 +30,7 @@ Revive accepts three command line parameters:
|
||||
* `formatter` - formatter to be used for the output. The currently available formatters are:
|
||||
* `default` - will output the warnings the same way that `golint` does.
|
||||
* `json` - outputs the warnings in JSON format.
|
||||
* `cli` - formats the warnings in a table.
|
||||
* `stylish` - formats the warnings in a table.
|
||||
|
||||
### Configuration
|
||||
|
||||
@ -49,10 +49,10 @@ This will use the configuration file `defaults.toml`, the `default` formatter, a
|
||||
### Recommended Configuration
|
||||
|
||||
```shell
|
||||
revive -config config.toml -formatter cli github.com/mgechev/revive
|
||||
revive -config config.toml -formatter stylish github.com/mgechev/revive
|
||||
```
|
||||
|
||||
This will use `config.toml`, the `cli` formatter, and will run linting over the `github.com/mgechev/revive` package. Keep in mind that the `cli` formatter performs aggregation and grouping of the discovered problems in your code. This means that the output will be buffered and printed at once. If you want a streaming output use `default`.
|
||||
This will use `config.toml`, the `stylish` formatter, and will run linting over the `github.com/mgechev/revive` package. Keep in mind that the `stylish` formatter performs aggregation and grouping of the discovered problems in your code. This means that the output will be buffered and printed at once. If you want a streaming output use `default`.
|
||||
|
||||
## Available Rules
|
||||
|
||||
@ -69,9 +69,9 @@ This will use `config.toml`, the `cli` formatter, and will run linting over the
|
||||
|
||||
This section lists all the available formatters and provides a screenshot for each one.
|
||||
|
||||
### CLI
|
||||
### Stylish
|
||||
|
||||
![CLI formatter](/assets/cli-formatter.png)
|
||||
![Stylish formatter](/assets/stylish-formatter.png)
|
||||
|
||||
## Extension
|
||||
|
||||
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
@ -49,7 +49,7 @@ var allRules = append([]lint.Rule{
|
||||
}, defaultRules...)
|
||||
|
||||
var allFormatters = []lint.Formatter{
|
||||
&formatter.CLI{},
|
||||
&formatter.Stylish{},
|
||||
&formatter.JSON{},
|
||||
&formatter.Default{},
|
||||
}
|
||||
@ -202,7 +202,7 @@ func init() {
|
||||
const (
|
||||
configUsage = "path to the configuration TOML file (i.e. -config myconf.toml)"
|
||||
excludeUsage = "list of globs which specify files to be excluded (i.e. -exclude foo/...)"
|
||||
formatterUsage = "formatter to be used for the output (i.e. -formatter cli)"
|
||||
formatterUsage = "formatter to be used for the output (i.e. -formatter stylish)"
|
||||
)
|
||||
flag.StringVar(&configPath, "config", "", configUsage)
|
||||
flag.Var(&excludePaths, "exclude", excludeUsage)
|
||||
|
@ -14,15 +14,15 @@ const (
|
||||
warningEmoji = ""
|
||||
)
|
||||
|
||||
// CLI is an implementation of the Formatter interface
|
||||
// Stylish is an implementation of the Formatter interface
|
||||
// which formats the errors to JSON.
|
||||
type CLI struct {
|
||||
type Stylish struct {
|
||||
Metadata lint.FormatterMetadata
|
||||
}
|
||||
|
||||
// Name returns the name of the formatter
|
||||
func (f *CLI) Name() string {
|
||||
return "cli"
|
||||
func (f *Stylish) Name() string {
|
||||
return "stylish"
|
||||
}
|
||||
|
||||
func formatFailure(failure lint.Failure, severity lint.Severity) []string {
|
||||
@ -37,7 +37,7 @@ func formatFailure(failure lint.Failure, severity lint.Severity) []string {
|
||||
}
|
||||
|
||||
// Format formats the failures gotten from the lint.
|
||||
func (f *CLI) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) {
|
||||
func (f *Stylish) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) {
|
||||
var result [][]string
|
||||
var totalErrors = 0
|
||||
var total = 0
|
Loading…
Reference in New Issue
Block a user