Skip to content

Commit

Permalink
lint rule for [A-z]
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok Menghrajani committed May 7, 2012
1 parent 869b2ed commit db71093
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions riskybird_lint.opa
Expand Up @@ -22,8 +22,6 @@
*
* - detect incorrect ranges, e.g. a{3,1} or [z-a]
*
* - detect [A-z] (often used by laziness).
*
* - incorrect group reference
* "(a)\2" or "(a)\2(b)"
*
Expand Down Expand Up @@ -181,6 +179,10 @@ module RegexpLinter {
} else if (RegexpLinterHelper.range_exists(r, state.ranges)) {
status = {error: {range_not_used: r}}
{ ~status, ranges: state.ranges }
} else if (r.rstart == "A" && r.rend == "z") {
e = {error: {lint_rule: 6, title: "Progammer laziness",
body: "When you write A-z instead of A-Za-z, you are including 6 extra characters!"}}
{status: e, ranges: state.ranges}
}
else {
ranges = List.cons(r, state.ranges)
Expand Down
1 change: 1 addition & 0 deletions riskybird_unittest.opa
Expand Up @@ -80,6 +80,7 @@ expect_lint_error("complex overlapping", "[fg-ia-ec-j]")
expect_lint_error("complex inclusion", "[fg-ia-ec-h]")
expect_lint_error("invalid range", "[z-a]")
expect_lint_error("useless range", "[x-x]")
expect_lint_error("typical lazyness", "[0-9A-z]")

// other tests

Expand Down

0 comments on commit db71093

Please sign in to comment.