Skip to content

Commit

Permalink
fixes issue #98 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavacava authored and mgechev committed Jan 18, 2019
1 parent b4cc152 commit c878d30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions fixtures/line-length-limit.go
Expand Up @@ -5,3 +5,13 @@ import "fmt"
func foo(a, b int) {
fmt.Printf("single line characters out of limit") // MATCH /line is 105 characters, out of limit 100/
}

// revive:disable-next-line:line-length-limit
// The length of this comment line is over 80 characters, this is bad for readability.

// Warn: the testing framework does not allow to check for failures in comments

func toto() {
// revive:disable-next-line:line-length-limit
fmt.Println("This line is way too long. In my opinion, it should be shortened.")
}
9 changes: 4 additions & 5 deletions lint/file.go
Expand Up @@ -127,7 +127,7 @@ type enableDisableConfig struct {
}

func (f *File) disabledIntervals(rules []Rule) disabledIntervalsMap {
re := regexp.MustCompile(`^\s*revive:(enable|disable)(?:-(line|next-line))?(:|\s|$)`)
re := regexp.MustCompile(`^\s*revive:(enable|disable)(?:-(line|next-line))?(:)?([^\s]*)?(\s|$)`)

enabledDisabledRulesMap := make(map[string][]enableDisableConfig)

Expand Down Expand Up @@ -199,11 +199,10 @@ func (f *File) disabledIntervals(rules []Rule) disabledIntervalsMap {
if len(parts) == 0 {
return
}
str := re.FindString(text)
ruleNamesString := strings.Split(text, str)

ruleNames := []string{}
if len(ruleNamesString) == 2 {
tempNames := strings.Split(ruleNamesString[1], ",")
if len(parts) > 4 {
tempNames := strings.Split(parts[4], ",")
for _, name := range tempNames {
name = strings.Trim(name, "\n")
if len(name) > 0 {
Expand Down

0 comments on commit c878d30

Please sign in to comment.