use of org.sonar.maven.model.LocatedAttribute 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);
}
}
}
use of org.sonar.maven.model.LocatedAttribute in project sonar-java by SonarSource.
the class PatternMatcherTest method should_match_patterns.
@Test
public void should_match_patterns() {
matcher = new PatternMatcher("[a-z]*");
assertThat(matcher.test(null)).isFalse();
assertThat(matcher.test(new LocatedAttribute("test"))).isTrue();
assertThat(matcher.test(new LocatedAttribute("012"))).isFalse();
}
use of org.sonar.maven.model.LocatedAttribute in project sonar-java by SonarSource.
the class LocatedAttributeMatcherTest method matcher_always_matching_always_match.
@Test
public void matcher_always_matching_always_match() {
LocatedAttributeMatcher matcher = LocatedAttributeMatcher.any();
assertThat(matcher.test(null)).isTrue();
assertThat(matcher.test(new LocatedAttribute("test"))).isTrue();
}
use of org.sonar.maven.model.LocatedAttribute in project sonar-java by SonarSource.
the class MavenDependencyMatcherTest method newDependency.
private static Dependency newDependency(String groupId, String artifactId, @Nullable String version) {
Dependency dependency = new Dependency();
dependency.setGroupId(new LocatedAttribute(groupId));
dependency.setArtifactId(new LocatedAttribute(artifactId));
if (version != null) {
dependency.setVersion(new LocatedAttribute(version));
}
return dependency;
}
Aggregations