Skip to content

Commit

Permalink
Merge pull request #136 from ray-x/master
Browse files Browse the repository at this point in the history
Add lint severity setting
  • Loading branch information
mattn authored Jun 6, 2021
2 parents 0e684cd + 7fac68c commit 8a04675
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions langserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Language struct {
LintIgnoreExitCode bool `yaml:"lint-ignore-exit-code" json:"lintIgnoreExitCode"`
LintCategoryMap map[string]string `yaml:"lint-category-map" json:"LintCategoryMap"`
LintSource string `yaml:"lint-source" json:"lintSource"`
LintSeverity int `yaml:"lint-severity" json:"lintSeverity"`
FormatCommand string `yaml:"format-command" json:"formatCommand"`
FormatStdin bool `yaml:"format-stdin" json:"formatStdin"`
SymbolCommand string `yaml:"symbol-command" json:"symbolCommand"`
Expand All @@ -78,7 +79,7 @@ func NewHandler(config *Config) jsonrpc2.Handler {
config.Logger = log.New(os.Stderr, "", log.LstdFlags)
}

var handler = &langHandler{
handler := &langHandler{
loglevel: config.LogLevel,
logger: config.Logger,
commands: *config.Commands,
Expand Down Expand Up @@ -319,7 +320,6 @@ func isFilename(s string) bool {
}
}
return false

}

func (h *langHandler) lint(ctx context.Context, uri DocumentURI) ([]Diagnostic, error) {
Expand Down Expand Up @@ -416,6 +416,7 @@ func (h *langHandler) lint(ctx context.Context, uri DocumentURI) ([]Diagnostic,
if config.LintSource != "" {
source = &configs[i].LintSource
}

scanner := efms.NewScanner(bytes.NewReader(b))
for scanner.Scan() {
entry := scanner.Entry()
Expand Down Expand Up @@ -456,8 +457,10 @@ func (h *langHandler) lint(ctx context.Context, uri DocumentURI) ([]Diagnostic,
if len(config.LintCategoryMap) > 0 {
entry.Type = []rune(config.LintCategoryMap[string(entry.Type)])[0]
}

severity := 1
if config.LintSeverity != 0 {
severity = config.LintSeverity
}
switch {
case entry.Type == 'E' || entry.Type == 'e':
severity = 1
Expand Down

0 comments on commit 8a04675

Please sign in to comment.