Skip to content

Commit

Permalink
Merge branch 'hotfix/V2.28.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
gquerret committed Oct 8, 2024
2 parents 4fdb9e2 + 09cac9c commit 24c6bdd
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 81 deletions.
16 changes: 8 additions & 8 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>coverage-report</artifactId>
Expand All @@ -21,37 +21,37 @@
<dependency>
<groupId>eu.rssw.openedge.rcode</groupId>
<artifactId>rcode-reader</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion database-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion listing-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions openedge-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
Expand All @@ -23,12 +23,12 @@
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
13 changes: 4 additions & 9 deletions openedge-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
Expand All @@ -30,22 +30,17 @@
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.28.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sonar.plugins.openedge.foundation;

import static java.util.Objects.requireNonNull;

/**
* Imported from commons-io
*/
public class FilenameUtils {

private static final int NOT_FOUND = -1;

private static final char EXTENSION_SEPARATOR = '.';
/**
* The Unix separator character.
*/
private static final char UNIX_SEPARATOR = '/';

/**
* The Windows separator character.
*/
private static final char WINDOWS_SEPARATOR = '\\';

private FilenameUtils() {
// Only static methods here
}

public static String getExtension(String filename) {
requireNonNull(filename);
final int index = indexOfExtension(filename);
if (index == NOT_FOUND) {
return "";
} else {
return filename.substring(index + 1);
}
}

public static String removeExtension(final String fileName) {
requireNonNull(fileName);

final int index = indexOfExtension(fileName);
if (index == NOT_FOUND) {
return fileName;
}
return fileName.substring(0, index);
}

public static String getBaseName(final String fileName) {
return removeExtension(getName(fileName));
}

public static String getName(final String fileName) {
if (fileName == null) {
return null;
}
return fileName.substring(indexOfLastSeparator(fileName) + 1);
}

private static int indexOfExtension(String filename) {
final int extensionPos = filename.lastIndexOf(EXTENSION_SEPARATOR);
final int lastSeparator = indexOfLastSeparator(filename);
return lastSeparator > extensionPos ? NOT_FOUND : extensionPos;
}

private static int indexOfLastSeparator(String filename) {
final int lastUnixPos = filename.lastIndexOf(UNIX_SEPARATOR);
final int lastWindowsPos = filename.lastIndexOf(WINDOWS_SEPARATOR);
return Math.max(lastUnixPos, lastWindowsPos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
import java.util.stream.Collectors;
import java.util.zip.GZIPInputStream;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.prorefactor.core.schema.IDatabase;
import org.prorefactor.core.schema.Schema;
import org.prorefactor.proparse.classdoc.ClassDocumentation;
Expand Down Expand Up @@ -916,7 +914,11 @@ private Collection<IDatabase> readSchemaFromProp1(String dbList) {
desc = DatabaseDescription.deserialize(is, dbName);
} catch (IOException caught) {
LOG.error("Unable to deserialize from '" + serFile + "', deleting file", caught);
FileUtils.deleteQuietly(serFile);
try {
java.nio.file.Files.delete(serFile.toPath());
} catch (IOException uncaught) {
// Nothing
}
}
} else {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package org.sonar.plugins.openedge.sensor;

import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.SonarProduct;
Expand All @@ -31,6 +30,7 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.plugins.openedge.api.Constants;
import org.sonar.plugins.openedge.foundation.FilenameUtils;
import org.sonar.plugins.openedge.foundation.OpenEdgeMetrics;

public class OpenEdgeSensor implements Sensor {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.sonar.plugins.openedge.foundation;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.expectThrows;
import static org.sonar.plugins.openedge.foundation.FilenameUtils.getExtension;
import static org.sonar.plugins.openedge.foundation.FilenameUtils.removeExtension;
import static org.sonar.plugins.openedge.foundation.FilenameUtils.getBaseName;
import static org.sonar.plugins.openedge.foundation.FilenameUtils.getName;

import org.testng.annotations.Test;

public class FilenameUtilsTest {

@Test
public void testGetExtension() {
assertEquals(getExtension("C:\\foo\\bar\\filename.txt"), "txt");
assertEquals(getExtension("filename.txt"), "txt");
assertEquals(getExtension("filename.t"), "t");
assertEquals(getExtension("filename"), "");
assertEquals(getExtension("foo.bar\\filename"), "");
expectThrows(NullPointerException.class, () -> getExtension(null));
}

@Test
public void testRemoveExtension() {
assertEquals(removeExtension("C:\\foo\\bar\\filename.txt"), "C:\\foo\\bar\\filename");
assertEquals(removeExtension("filename.txt"), "filename");
assertEquals(removeExtension("filename.t"), "filename");
assertEquals(removeExtension("filename"), "filename");
expectThrows(NullPointerException.class, () -> removeExtension(null));
}

@Test
public void testGetBaseName() {
assertEquals(getBaseName("C:\\foo\\bar\\filename.txt"), "filename");
assertEquals(getBaseName("filename.txt"), "filename");
assertEquals(getBaseName("filename.t"), "filename");
assertEquals(getBaseName("filename"), "filename");
expectThrows(NullPointerException.class, () -> getBaseName(null));
}

@Test
public void testGetName() {
assertEquals(getName("C:\\foo\\bar\\filename.txt"), "filename.txt");
assertEquals(getName("filename.txt"), "filename.txt");
assertEquals(getName("filename.t"), "filename.t");
assertEquals(getName("filename"), "filename");
assertEquals(getName(null), null);
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
<packaging>pom</packaging>

<name>OpenEdge plugin for SonarQube</name>
Expand Down
2 changes: 1 addition & 1 deletion profiler-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
Expand Down
10 changes: 2 additions & 8 deletions proparse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.rssw</groupId>
<artifactId>sonar-openedge</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</parent>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>eu.rssw.openedge.rcode</groupId>
<artifactId>rcode-reader</artifactId>
<version>2.28.2</version>
<version>2.28.3</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
Expand Down Expand Up @@ -82,12 +82,6 @@
<version>1.7.36</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 2 additions & 1 deletion proparse/src/main/java/org/prorefactor/treeparser/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void addBufferScopeReferences(BufferScope bufferScope) {
// References do not get added to DO blocks.
if (blockStatementNode.getNodeType() != ABLNodeType.DO)
bufferScopes.add(bufferScope);
if (parentScopeBlock != null && bufferScope.getSymbol().getScope().getRootBlock() != this) {
if ((parentScopeBlock != null) && (bufferScope.getSymbol() != null)
&& bufferScope.getSymbol().getScope().getRootBlock() != this) {
parentScopeBlock.addBufferScopeReferences(bufferScope);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
********************************************************************************/
package org.prorefactor.core;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;

import org.apache.commons.io.FileUtils;
import org.prorefactor.core.util.SportsSchema;
import org.prorefactor.core.util.TP01FramesTreeLister;
import org.prorefactor.core.util.UnitTestProparseSettings;
Expand Down Expand Up @@ -56,7 +56,7 @@ public void test01() throws IOException {
nodeLister.print(' ');
writer.close();

assertTrue(FileUtils.contentEquals(new File(expectName), outFile));
assertEquals(Files.readAllBytes(new File(expectName).toPath()), Files.readAllBytes(outFile.toPath()));
}

}
Loading

0 comments on commit 24c6bdd

Please sign in to comment.