Permalink
Browse files

lint rule for [A-z]

  • Loading branch information...
Alok Menghrajani
Alok Menghrajani committed May 7, 2012
1 parent 869b2ed commit db71093fc56fb8d5cddd6f3c50ebfab078acc050
Showing with 5 additions and 2 deletions.
  1. +4 −2 riskybird_lint.opa
  2. +1 −0 riskybird_unittest.opa
View
@@ -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)"
*
@@ -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)
View
@@ -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

0 comments on commit db71093

Please sign in to comment.