Skip to content

Commit

Permalink
Fix haml-lint MultilineScript offense
Browse files Browse the repository at this point in the history
A false positive is triggered by the linter MultilineScript, so this
explains the switch from =~ to match?.

On top of this, since Ruby 2.4, `String#match?`, `Regexp#match?` and
`Symbol#match?` have been added.  The methods are faster than
`match`/`=~`.  Because the methods avoid creating a `MatchData` object
or saving backref. So, when `MatchData` is not used, use `match?`
instead of `match`/`=~`.
  • Loading branch information
dmarcoux committed Aug 3, 2018
1 parent 646b53d commit 8864662
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/api/.haml-lint_todo.yml
Expand Up @@ -41,11 +41,6 @@ linters:
- "app/views/webui/user/show.html.haml"
- "app/views/webui/cloud/azure/configurations/show.html.haml"

# Offense count: 1
MultilineScript:
exclude:
- "app/views/webui/package/_rpmlint_log.html.haml"

# Offense count: 6
MultilinePipe:
exclude:
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/views/webui/package/_rpmlint_log.html.haml
@@ -1,7 +1,7 @@
- @log.lines.each do |line|
- if line =~ /\w+(?:\.\w+)+: W: /
- if line.match?(/\w+(?:\.\w+)+: W: /)
= content_tag(:span, line.strip, style: 'color: olive;')
- elsif line =~ /\w+(?:\.\w+)+: E: /
- elsif line.match?(/\w+(?:\.\w+)+: E: /)
= content_tag(:span, line.strip, style: 'color: red;')
- else
= line.strip

0 comments on commit 8864662

Please sign in to comment.