10: Create SuppressWarningsPlugin
This commit is contained in:
@@ -89,4 +89,10 @@ public class PluginModule {
|
||||
public Plugin externalStoragePlugin(GlobMatcher globMatcher, XmlHelper xmlHelper, ParentNodeFinder parentNodeFinder) {
|
||||
return new ExternalStoragePlugin(globMatcher, xmlHelper, parentNodeFinder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
public Plugin suppressWarningsPlugin(GlobMatcher globMatcher, XmlHelper xmlHelper) {
|
||||
return new SuppressWarningsPlugin(globMatcher, xmlHelper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.bartek.esa.core.plugin;
|
||||
|
||||
import com.bartek.esa.core.archetype.JavaPlugin;
|
||||
import com.bartek.esa.core.model.enumeration.Severity;
|
||||
import com.bartek.esa.core.xml.XmlHelper;
|
||||
import com.bartek.esa.file.matcher.GlobMatcher;
|
||||
import com.github.javaparser.ast.CompilationUnit;
|
||||
import com.github.javaparser.ast.expr.AnnotationExpr;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SuppressWarningsPlugin extends JavaPlugin {
|
||||
|
||||
@Inject
|
||||
public SuppressWarningsPlugin(GlobMatcher globMatcher, XmlHelper xmlHelper) {
|
||||
super(globMatcher, xmlHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CompilationUnit compilationUnit) {
|
||||
compilationUnit.findAll(AnnotationExpr.class).stream()
|
||||
.filter(expr -> expr.getName().getIdentifier().equals("SuppressWarnings"))
|
||||
.forEach(expr -> addIssue(Severity.WARNING, getLineNumberFromExpression(expr), expr.toString()));
|
||||
}
|
||||
}
|
||||
@@ -83,3 +83,7 @@ com.bartek.esa.core.plugin.StrictModePlugin=Strict mode is turned on.\n\
|
||||
com.bartek.esa.core.plugin.ExternalStoragePlugin=External storage state is not checked.\n\
|
||||
There is attempt to access to external storage without checking its state.\n\
|
||||
External storage state should be checked through 'Environment.getExternalStorageState()' method.
|
||||
|
||||
com.bartek.esa.core.plugin.SuppressWarningsPlugin=@SuppressWarnings annotation was found.\n\
|
||||
The @SuppressWarnings annotation might be hiding useful warnings.\n\
|
||||
Consider removing it.
|
||||
Reference in New Issue
Block a user