Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
teaching:labs:mdse:2013:bug_descriptions:jt-bug-cor103 [2013/10/14 10:05] jaspreet_kaur |
teaching:labs:mdse:2013:bug_descriptions:jt-bug-cor103 [2018/05/09 01:59] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Bug JT_Category_Number ====== | ||
+ | ===== Inspired by ===== | ||
+ | |||
+ | * [[http://findbugs.sourceforge.net/bugDescriptions.html#RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION | RE_BAD_SYNTAX_FOR_REGULAR_EXPRESSION]] | ||
+ | |||
+ | ===== Original Description ===== | ||
+ | |||
+ | The code here uses a regular expression that is invalid according to the syntax for regular expressions. This statement will throw a PatternSyntaxException when executed. -- 2013-10-14 | ||
+ | |||
+ | |||
+ | ===== Detailed Description ===== | ||
+ | |||
+ | Syntax errors also called as parsing errors, are caught by ParseSyntaxException in Java whenever incorrect syntax is passed in any regular expression. | ||
+ | |||
+ | ===== Sample Problem Scenario ===== | ||
+ | <code Java> | ||
+ | public class PatternExample { | ||
+ | public static void main(String[] args) { | ||
+ | Pattern pattern = Pattern.compile('.xx.'); | ||
+ | Matcher matcher = pattern.matcher('MxxY'); | ||
+ | System.out.println('Input String matches regex - '+matcher.matches()); | ||
+ | // bad regular expression | ||
+ | pattern = Pattern.compile('*xx*'); | ||
+ | } | ||
+ | } | ||
+ | </Code> | ||
+ | |||
+ | ===== Sample Fix ===== | ||
+ | <code Java> | ||
+ | String str = 'bbb'; | ||
+ | System.out.println('Using String matches method: '+str.matches('.bb')); | ||
+ | System.out.println('Using Pattern matches method: '+Pattern.matches('.bb', str)); | ||
+ | </Code> | ||
+ | |||
+ | ===== Evaluation Results ===== | ||
+ | |||
+ | ^ Benchmark project ^ Precision ^^^ Recall ^^^ | ||
+ | | | FB | JT | Delta | FB | JT | Delta | | ||
+ | | Project ... | ...% | ...% | ...% | ...% | ...% | ...% | | ||
+ | | Project ... | ...% | ...% | ...% | ...% | ...% | ...% | | ||
+ | FB = FindBugs, JT = JTransformer, Delta = JTransformer - FindBugs | ||
+ |