Skip to content

Commit

Permalink
Fixed some sonar warnings
Browse files Browse the repository at this point in the history
Björn Ekryd committed Jan 29, 2023
1 parent fcf2295 commit 3d0a9be
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions sorter/src/main/java/sortpom/wrapper/ElementWrapperCreator.java
Original file line number Diff line number Diff line change
@@ -36,19 +36,19 @@ public void setup(PluginParameters pluginParameters) {
}

Wrapper<Element> createWrapper(Element element) {
boolean sortedBySortOrderFile = elementNameSortOrderMap.containsElement(element);
var sortedBySortOrderFile = elementNameSortOrderMap.containsElement(element);
if (sortedBySortOrderFile) {
if (isDependencyElement(element)) {
return createdDependencySortedWrapper(element);
}
if (isExclusionElement(element)) {
ExclusionSortedWrapper exclusionSortedWrapper =
var exclusionSortedWrapper =
new ExclusionSortedWrapper(element, elementNameSortOrderMap.getSortOrder(element));
exclusionSortedWrapper.setSortOrder(sortDependencyExclusions);
return exclusionSortedWrapper;
}
if (isPluginElement(element)) {
PluginSortedWrapper pluginSortedWrapper =
var pluginSortedWrapper =
new PluginSortedWrapper(element, elementNameSortOrderMap.getSortOrder(element));
pluginSortedWrapper.setSortOrder(sortPlugins);
return pluginSortedWrapper;
@@ -69,7 +69,7 @@ Wrapper<Element> createWrapper(Element element) {

/** Create separate wrapper for dependency and dependency mgmt. Dependency setting is fallback */
private DependencySortedWrapper createdDependencySortedWrapper(Element element) {
DependencySortedWrapper dependencySortedWrapper =
var dependencySortedWrapper =
new DependencySortedWrapper(element, elementNameSortOrderMap.getSortOrder(element));
if (isDependencyElementInManagement(element) && !sortDependencyManagement.isNoSorting()) {
dependencySortedWrapper.setSortOrder(sortDependencyManagement);
@@ -124,8 +124,8 @@ private boolean isPropertyElement(final Element element) {
if (!sortProperties) {
return false;
}
String deepName = getDeepName(element);
boolean inTheRightPlace =
var deepName = getDeepName(element);
var inTheRightPlace =
deepName.startsWith("/project/properties/")
|| deepName.startsWith("/project/profiles/profile/properties/");
return inTheRightPlace && isElementParentName(element, "properties");
Original file line number Diff line number Diff line change
@@ -29,9 +29,9 @@ void setUp() {

@Test
void scanNoInstructionsShouldWork() {
String xml =
var xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ " <artifactId>sortpom</artifactId>\n"
+ " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n"
+ " <groupId>sortpom</groupId>\n"
@@ -53,9 +53,9 @@ void scanNoInstructionsShouldWork() {

@Test
void correctIgnoreShouldNotReportError() {
String xml =
var xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ " <artifactId>sortpom</artifactId>\n"
+ " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n"
+ " <groupId>sortpom</groupId>\n"
@@ -93,9 +93,9 @@ public static Stream<Arguments> illegalProcessingInstructions() {
@MethodSource("illegalProcessingInstructions")
void illegalProcessingInstructionsShouldReportError(
String xmlProcessingInstruction, String expectedErrorMsg) {
String xml =
var xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ " <artifactId>sortpom</artifactId>\n"
+ " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n"
+ " <groupId>sortpom</groupId>\n"
@@ -120,9 +120,9 @@ void illegalProcessingInstructionsShouldReportError(

@Test
void multipleErrorsShouldBeReportedInLogger() {
String xml =
var xml =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd\">\n"
+ " <artifactId>sortpom</artifactId>\n"
+ " <description name=\"pelle\" id=\"id\" other=\"övrigt\">Här använder vi åäö</description>\n"
+ " <groupId>sortpom</groupId>\n"

0 comments on commit 3d0a9be

Please sign in to comment.