Skip to content

Commit

Permalink
WINDUPRULE-355 Move informational rules to a dedicated issue category (
Browse files Browse the repository at this point in the history
…#1331)

* add new issue category 'information'

* move pom.xml found issue to information category

* move ejb-jar.xml and web.xml occurrence found to information issue category

* add check for potential issues in WindupArchitectureMediumBinaryModeTest
  • Loading branch information
jeichler authored and mrizzi committed Sep 14, 2018
1 parent 50c62cc commit 681c9d6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class IssueCategoryRegistry
public static final String OPTIONAL = "optional";
public static final String POTENTIAL = "potential";
public static final String CLOUD_MANDATORY = "cloud-mandatory";
public static final String INFORMATION = "information";
public static final String DEFAULT = OPTIONAL;

private Map<String, IssueCategory> issueCategories = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -167,5 +168,6 @@ private void addDefaults()
this.issueCategories.putIfAbsent(OPTIONAL, new IssueCategory(OPTIONAL, IssueCategoryRegistry.class.getCanonicalName(), "Optional", OPTIONAL, 1000, true));
this.issueCategories.putIfAbsent(POTENTIAL, new IssueCategory(POTENTIAL, IssueCategoryRegistry.class.getCanonicalName(), "Potential Issues", POTENTIAL, 1000, true));
this.issueCategories.putIfAbsent(CLOUD_MANDATORY, new IssueCategory(CLOUD_MANDATORY, IssueCategoryRegistry.class.getCanonicalName(), "Cloud Mandatory", CLOUD_MANDATORY, 1000, true));
this.issueCategories.putIfAbsent(INFORMATION, new IssueCategory(INFORMATION, IssueCategoryRegistry.class.getCanonicalName(), "Information", INFORMATION, 1000, true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jboss.windup.graph.model.WindupFrame;
import org.jboss.windup.graph.service.GraphService;
import org.jboss.windup.graph.service.Service;
import org.jboss.windup.reporting.category.IssueCategoryRegistry;
import org.jboss.windup.reporting.model.TechnologyTagLevel;
import org.jboss.windup.reporting.model.TechnologyTagModel;
import org.jboss.windup.reporting.service.ClassificationService;
Expand Down Expand Up @@ -310,7 +311,7 @@ private void extractMetadata(GraphRewrite event, EvaluationContext context, XmlF
ClassificationService classificationService = new ClassificationService(event.getGraphContext());
TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext());
TechnologyTagModel technologyTag = technologyTagService.addTagToFileModel(xmlModel, TECH_TAG, TECH_TAG_LEVEL);
classificationService.attachClassification(event, context, xmlModel, "EJB XML", "Enterprise Java Bean XML Descriptor.");
classificationService.attachClassification(event, context, xmlModel, IssueCategoryRegistry.INFORMATION, "EJB XML", "Enterprise Java Bean XML Descriptor.");

// otherwise, it is a EJB-JAR XML.
if (xmlModel.getDoctype() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jboss.windup.config.query.QueryPropertyComparisonType;
import org.jboss.windup.config.ruleprovider.IteratingRuleProvider;
import org.jboss.windup.graph.GraphContext;
import org.jboss.windup.reporting.category.IssueCategoryRegistry;
import org.jboss.windup.reporting.model.TechnologyTagLevel;
import org.jboss.windup.reporting.model.TechnologyTagModel;
import org.jboss.windup.reporting.service.ClassificationService;
Expand Down Expand Up @@ -119,7 +120,7 @@ private void addWebXmlMetadata(GraphRewrite event, EvaluationContext evaluationC
ClassificationService classificationService = new ClassificationService(context);
TechnologyTagService technologyTagService = new TechnologyTagService(context);

classificationService.attachClassification(event, evaluationContext, xml, "Web XML", " Web Application Deployment Descriptors");
classificationService.attachClassification(event, evaluationContext, xml, IssueCategoryRegistry.INFORMATION, "Web XML", " Web Application Deployment Descriptors");
TechnologyTagModel technologyTag = technologyTagService.addTagToFileModel(xml, TECH_TAG, TECH_TAG_LEVEL);
WebXmlService webXmlService = new WebXmlService(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jboss.windup.graph.model.resource.FileModel;
import org.jboss.windup.graph.service.FileService;
import org.jboss.windup.graph.service.GraphService;
import org.jboss.windup.reporting.category.IssueCategoryRegistry;
import org.jboss.windup.reporting.model.TechnologyTagLevel;
import org.jboss.windup.reporting.service.ClassificationService;
import org.jboss.windup.reporting.service.TechnologyTagService;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel
if (mavenProjectModel != null)
{
// add classification information to file.
classificationService.attachClassification(event, context, payload, "Maven POM (pom.xml)", "Maven Project Object Model (POM) File");
classificationService.attachClassification(event, context, payload, IssueCategoryRegistry.INFORMATION, "Maven POM (pom.xml)", "Maven Project Object Model (POM) File");
technologyTagService.addTagToFileModel(payload, "Maven XML", TechnologyTagLevel.INFORMATIONAL);

ArchiveModel archiveModel = payload.getArchive();
Expand Down Expand Up @@ -361,7 +362,7 @@ public MavenProjectModel extractMavenProjectModel(GraphRewrite event, Evaluation
fileLocation.setColumnNumber(columnNumber);
fileLocation.setLength(node.toString().length());
fileLocation.setFile(xmlFileModel);
List<FileLocationModel> fileLocationList = new ArrayList<FileLocationModel>(1);
List<FileLocationModel> fileLocationList = new ArrayList<>(1);
fileLocationList.add(fileLocation);
projectDep.setFileLocationReference(fileLocationList);
mavenProjectModel.addDependency(projectDep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,24 @@ private void validateReportIndex(GraphContext graphContext)

reportIndex.loadPage(mainReportPath);
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("mandatory", 1, 3));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("optional", 91, 636));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("optional", 80, 636));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("potential", 0, 0));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("cloud-mandatory", 2, 10));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("information", 11, 0));

reportIndex.loadPage(secondAppPath);
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("mandatory", 1, 3));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("optional", 91, 636));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("optional", 80, 636));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("potential", 0, 0));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("cloud-mandatory", 2, 10));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("information", 11, 0));

reportIndex.loadPage(sharedLibsPath);
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("mandatory", 1, 3));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("optional", 87, 584));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("optional", 77, 584));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("potential", 0, 0));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("cloud-mandatory", 2, 10));
Assert.assertTrue(reportIndex.checkIncidentByCategoryRow("information", 10, 0));
}

private void validateJarDependencyReport(GraphContext graphContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,11 @@ private void validateReportIndex(GraphContext context)
TestReportIndexReportUtil util = new TestReportIndexReportUtil();
util.loadPage(appReportPath);

Assert.assertTrue(util.checkIncidentByCategoryRow("optional", 301, 2306));
Assert.assertTrue(util.checkIncidentByCategoryRow("optional", 291, 2306));
Assert.assertTrue(util.checkIncidentByCategoryRow("mandatory", 0, 0));
Assert.assertTrue(util.checkIncidentByCategoryRow("information", 10, 0));
Assert.assertTrue(util.checkIncidentByCategoryRow("cloud-mandatory", 3, 3));
Assert.assertTrue(util.checkIncidentByCategoryRow("potential", 0, 0));
}

private void validateTagsInSourceReport(GraphContext context) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private void validateCsvReport(Path reportDirectory) throws Exception
Path csvPath = reportDirectory.resolve("src_example.csv");
Map<String, Boolean> expectedRegexMatches = new HashMap<>();
expectedRegexMatches.put("\"Rule Id\",\"Issue Category\".*", false);
expectedRegexMatches.put("\"DiscoverWebXmlRuleProvider_1\",\"optional\",\"Web XML\",\" Web Application Deployment Descriptors\",\"\",\"src_example\",\"web.xml\".*", false);
expectedRegexMatches.put("\"DiscoverWebXmlRuleProvider_1\",\"information\",\"Web XML\",\" Web Application Deployment Descriptors\",\"\",\"src_example\",\"web.xml\".*", false);

try (BufferedReader fileReader = new BufferedReader(new FileReader(csvPath.toFile())))
{
Expand Down

0 comments on commit 681c9d6

Please sign in to comment.