Re: [Codenarc-developer] SuppressWarnings refactoring (may effect IDE plugins)
Brought to you by:
chrismair
From: Chris M. <chr...@ea...> - 2011-09-11 18:14:18
|
Great stuff, Hamlet. I appreciate the simplification of the rule classes, and being able to get rid of those *Ex methods. I ran the new code (0.16) against Grails and Gradle source and encountered a couple minor bugs, and checked in the fixes. The performance difference between 0.15 and 0.16 is big! Run times for Grails + Gradle source, with my sample set of 178 rules enabled: CodeNarc 0.15 - average ~ 160 seconds CodeNarc 0.16 - average ~ 75 seconds Sweet! Thanks, Chris -----Original Message----- From: Hamlet D'Arcy [mailto:ham...@gm...] Sent: Saturday, September 10, 2011 5:16 AM To: Cod...@li...; Cédric CHAMPEAU; René Scheibe Subject: [Codenarc-developer] SuppressWarnings refactoring (may effect IDE plugins) Hi everyone, This weekend I redesigned how the @SuppressWarnings annotations are handled by CodeNarc. It may affect IDE support (but maybe not). Previously, the @SuppressWarnings were handled by the AbstractAstVisitor class. The problem with this is that not all rules subclass this class, so not all rules respect @SuppressWarnings. Also, a subclass could sometimes accidentally ignore the annotation. Also, the old design made it difficult to support suppressions on parameters and general expressions. The design has none of these problems and it will perform better as well. Also, by removing the suppression complexity from the visitors, it makes those classes more extensible. Basically, it needs to be done for the two big features I have planned: type inference and performance. The new design moves the suppress warning functionality to a new object: SuppressionAnalyzer. This object is invoked by any of the other Analyzer objects, like FilesystemSourceAnalyzer and DirectorySourceAnalyzer. If you have created a custom subclass of Analyzer, then you need to update your code. If you have not created a custom subclass then do nothing and be happy and quit reading! If you have a custom analyzer, then your analyze(RuleSet):Results object needs to change. Here is what a typical implementation should look like: Results analyze(RuleSet ruleSet) { def allViolations = [] def suppressionService = new SuppressionAnalyzer(source) ruleSet.rules.each { rule -> if (!suppressionService.isRuleSuppressed(rule)) { def violations = rule.applyTo(source) violations.removeAll { suppressionService.isViolationSuppressed(it) } allViolations.addAll(violations) } } new VirtualResults(allViolations) } You can see that you just need to create the SuppressionAnalyzer object and then make sure it gets called correctly. The code is not checked in yet, but I expect it to be checked in later today. Thanks, -- Hamlet D'Arcy ham...@gm... ---------------------------------------------------------------------------- -- Malware Security Report: Protecting Your Business, Customers, and the Bottom Line. Protect your business and customers by understanding the threat from malware and how it can impact your online business. http://www.accelacomm.com/jaw/sfnl/114/51427462/ _______________________________________________ Codenarc-developer mailing list Cod...@li... https://lists.sourceforge.net/lists/listinfo/codenarc-developer |