roterdam / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 0 forks source link

Regex Checker tutorial needs updates #290

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I followed this tutorial 
(http://types.cs.washington.edu/checker-framework/tutorial/webpages/user-input-c
md.html), and ran the RegexChecker in step 2. Instead of getting only one error 
about the unverified user input, I got another error which is actually not an 
error from the checker:

ping128$ javac -processor checkers.regex.RegexChecker RegexExample.java
RegexExample.java:13: error: incompatible types in argument.
        Pattern pat = Pattern.compile(regex);
                                      ^
  found   : String
  required: @Regex String
RegexExample.java:18: error: invalid groups parameter 1. Only 0 groups are 
guaranteed to exist for mat.
                System.out.println("Group: " + mat.group(1));

Even though I added

if (!RegexUtil.isRegex(regex)) {...

from step3, I still got the second error.

Original issue reported on code.google.com by sping...@gmail.com on 14 Dec 2013 at 4:58

GoogleCodeExporter commented 9 years ago
Thanks for the comment. I also noticed this problem yesterday, but haven't 
updated the tutorial website yet. (Some other text in the tutorial is also 
inconsistent.)

You need to ensure that the regular expression is both well-formed and contains 
at least one capturing group. To do this, change the check to:

if (!RegexUtil.isRegex(regex, 1)) {...

I will file a separate issue to automatically infer the capturing groups from 
the Matcher.groupCount() comparison.

I have an updated tutorial locally that will go public soon.

Original comment by wdi...@gmail.com on 14 Dec 2013 at 5:16

GoogleCodeExporter commented 9 years ago
I've updated the title. The Regex Checker is doing the right things (though 
they can be enhanced to perform more flow refinement). The tutorial needs to be 
updated.

Original comment by wdi...@gmail.com on 14 Dec 2013 at 5:18

GoogleCodeExporter commented 9 years ago

Original comment by michael.ernst@gmail.com on 14 Dec 2013 at 5:28

GoogleCodeExporter commented 9 years ago
Added request for enhancement Issue 291 to improve flow refinement for the 
Regex Checker.

Original comment by wdi...@gmail.com on 14 Dec 2013 at 7:02

GoogleCodeExporter commented 9 years ago
Revision 2737b86130ef fixed user reported issue with the tutorial.   

Original comment by Suzanne....@gmail.com on 3 Jan 2014 at 12:04

GoogleCodeExporter commented 9 years ago
Revision 7a23fc10bba2 fixed an inconsistency between the command line and 
Eclipse versions of the tutorial. 

Original comment by Suzanne....@gmail.com on 3 Jan 2014 at 12:20

GoogleCodeExporter commented 9 years ago

Original comment by Jonathan...@gmail.com on 6 Jan 2014 at 6:53