use of org.sonar.java.checks.xml.maven.helpers.MavenDependencyCollector in project sonar-java by SonarSource.
the class DependencyWithSystemScopeCheck method scanFile.
@Override
public void scanFile(PomCheckContext context) {
List<Dependency> dependencies = new MavenDependencyCollector(context.getMavenProject()).allDependencies();
for (Dependency dependency : dependencies) {
LocatedAttribute scope = dependency.getScope();
if (scope != null && "system".equalsIgnoreCase(scope.getValue())) {
String message = "Update this scope.";
LocatedAttribute systemPath = dependency.getSystemPath();
List<PomCheckContext.Location> secondaries = getSecondary(systemPath);
if (systemPath != null) {
message = "Update this scope and remove the \"systemPath\".";
}
context.reportIssue(this, scope.startLocation().line(), message, secondaries);
}
}
}
Aggregations