Skip to content

Commit

Permalink
Merge branch 'release/V2.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
gquerret committed Jul 26, 2022
2 parents 4ac9693 + 807e89c commit 93e1c62
Show file tree
Hide file tree
Showing 69 changed files with 949 additions and 300 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline {
steps {
checkout([$class: 'GitSCM', branches: scm.branches, extensions: scm.extensions + [[$class: 'CleanCheckout']], userRemoteConfigs: scm.userRemoteConfigs])
script {
withEnv(["MVN_HOME=${tool name: 'Maven 3', type: 'hudson.tasks.Maven$MavenInstallation'}", "JAVA_HOME=${tool name: 'Corretto 8', type: 'jdk'}"]) {
withEnv(["MVN_HOME=${tool name: 'Maven 3', type: 'hudson.tasks.Maven$MavenInstallation'}", "JAVA_HOME=${tool name: 'Corretto 11', type: 'jdk'}"]) {
if (("main" == env.BRANCH_NAME) || ("master" == env.BRANCH_NAME)) {
sh "$MVN_HOME/bin/mvn -P release clean package verify deploy -Dgit.commit=\$(git rev-parse --short HEAD)"
} else if (("develop" == env.BRANCH_NAME) || env.BRANCH_NAME.startsWith("release") || env.BRANCH_NAME.startsWith("hotfix")) {
Expand Down
16 changes: 8 additions & 8 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>coverage-report</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>

<name>JaCoCo report</name>
<description>Fake module for code coverage report in SonarQube</description>
Expand All @@ -20,37 +20,37 @@
<dependency>
<groupId>eu.rssw.openedge.rcode</groupId>
<artifactId>rcode-reader</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
</dependencies>

Expand Down
6 changes: 3 additions & 3 deletions database-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>

<name>OpenEdge database definition lexer and parser</name>
<description>OpenEdge dump files parser</description>
Expand Down Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.9.2</version>
<version>4.10.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down Expand Up @@ -112,7 +112,7 @@
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.9.2</version>
<version>4.10.1</version>
<executions>
<execution>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public Void visitAddField(AddFieldContext ctx) {
if (table != null) {
table.addField(field);
} else {
// Log error
// Log error
}

return visitChildren(ctx);
Expand All @@ -118,15 +118,15 @@ public Void visitFieldDescription(FieldDescriptionContext ctx) {

@Override
public Void visitFieldLabel(FieldLabelContext ctx) {
if (!fields.isEmpty())
if (!fields.isEmpty() && (ctx.QUOTED_STRING() != null))
fields.peek().setLabel(ctx.QUOTED_STRING().getText());

return null;
}

@Override
public Void visitFieldInitial(FieldInitialContext ctx) {
if (!fields.isEmpty() && ctx.QUOTED_STRING() != null)
if (!fields.isEmpty() && (ctx.QUOTED_STRING() != null))
fields.peek().setInitial(ctx.QUOTED_STRING().getText());

return null;
Expand All @@ -136,12 +136,15 @@ public Void visitFieldInitial(FieldInitialContext ctx) {
public Void visitFieldPosition(FieldPositionContext ctx) {
if (!fields.isEmpty()) {
try {
fields.peek().setPosition(Integer.parseInt(ctx.val.getText()));
} catch (Exception e) {}
fields.peek().setPosition(Integer.parseInt(ctx.val.getText()));
} catch (Exception e) {
// Nothing
}
}

return null;
}

@Override
public Void visitFieldExtent(FieldExtentContext ctx) {
if (!fields.isEmpty())
Expand Down Expand Up @@ -229,7 +232,7 @@ public Void visitTableDescription(TableDescriptionContext ctx) {
public Void visitTableDumpName(TableDumpNameContext ctx) {
if (!tables.isEmpty())
tables.peek().setDumpName(ctx.val.getText());

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,11 @@ public void testFieldAttributes() throws IOException {
assertEquals(f.getLabel(), "State");
assertEquals(f.getMaxWidth().intValue(), 40);
assertEquals(f.getFormat(), "x(20)");

f = db.getTable("Bin").getField("BinName");
assertNull(f.getLabel());
f = db.getTable("Bin").getField("BinNum");
assertEquals(f.getLabel(), "Bin Num");
}

}
2 changes: 1 addition & 1 deletion database-parser/src/test/resources/sp2k.df
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ ADD FIELD "BinNum" OF "Bin" AS integer
ADD FIELD "BinName" OF "Bin" AS character
FORMAT "x(30)"
INITIAL ""
LABEL "Bin Name"
LABEL ?
POSITION 6
MAX-WIDTH 60
HELP "Please enter a bin name"
Expand Down
2 changes: 1 addition & 1 deletion listing-parser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>

<name>OpenEdge listing so-called parser</name>
<description>OpenEdge listing files parser</description>
Expand Down
6 changes: 3 additions & 3 deletions openedge-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>

<name>OpenEdge checks</name>
<description>OpenEdge checks</description>
Expand Down Expand Up @@ -55,12 +55,12 @@
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>database-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>proparse</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.prorefactor.core.schema.IField;
import org.prorefactor.core.schema.ITable;
import org.prorefactor.treeparser.Primative;
import org.prorefactor.treeparser.Primitive;

import com.google.common.base.Preconditions;

Expand Down Expand Up @@ -69,17 +69,17 @@ public IField copyBare(ITable toTable) {
}

@Override
public void assignAttributesLike(Primative likePrim) {
public void assignAttributesLike(Primitive likePrim) {
throw new UnsupportedOperationException();
}

@Override
public Primative setDataType(DataType dataType) {
public Primitive setDataType(DataType dataType) {
throw new UnsupportedOperationException();
}

@Override
public Primative setExtent(int extent) {
public Primitive setExtent(int extent) {
throw new UnsupportedOperationException();
}

Expand Down
8 changes: 4 additions & 4 deletions openedge-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.rssw.sonar.openedge</groupId>
<artifactId>sonar-openedge-plugin</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
<packaging>sonar-plugin</packaging>

<name>OpenEdge plugin for SonarQube</name>
Expand Down Expand Up @@ -60,17 +60,17 @@
<dependency>
<groupId>eu.rssw.openedge.checks</groupId>
<artifactId>openedge-checks</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>listing-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>eu.rssw.openedge.parsers</groupId>
<artifactId>profiler-parser</artifactId>
<version>2.15.0</version>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package org.sonar.plugins.openedge.checks;

import java.util.List;

import org.prorefactor.core.ABLNodeType;
import org.prorefactor.core.JPNode;
import org.prorefactor.treeparser.ParseUnit;
Expand All @@ -30,20 +32,112 @@
import org.sonar.plugins.openedge.api.model.SqaleConstantRemediation;

@Rule(priority = Priority.BLOCKER, name = "Valid yet clumsy ABL syntax", tags = {"clumsy", "confusing"})
@SqaleConstantRemediation(value = "15min")
@SqaleConstantRemediation(value = "2min")
public class ClumsySyntax extends OpenEdgeProparseCheck {

@Override
public void execute(InputFile file, ParseUnit unit) {
if (unit.isInterface() || unit.isAbstractClass()) {
for (JPNode node : unit.getTopNode().queryStateHead(ABLNodeType.METHOD)) {
JPNode lastChild = node.getLastDescendant();
if (lastChild.getNodeType() == ABLNodeType.LEXCOLON) {
NewIssue issue = createIssue(file, node, "METHOD prototype declaration...", true);
addLocation(issue, file, lastChild, "... should end with a period and not a colon", true);
for (JPNode node : unit.getTopNode().queryStateHead()) {
switch (node.getNodeType()) {
case CATCH:
case CASE:
case DO:
case FOR:
case REPEAT:
case FINALLY:
case PROCEDURE:
handleDoBlock(file, node);
break;
case FUNCTION:
handleFunctionBlock(file, node);
break;
case METHOD:
handleMethodBlock(unit, file, node);
break;
default:
handleStatement(file, node);
}
}
}

private void handleFunctionBlock(InputFile file, JPNode node) {
List<JPNode> ch = node.getDirectChildren();
boolean containsForward = ch.stream().map(JPNode::getNodeType).anyMatch(type -> type == ABLNodeType.FORWARDS);
boolean containsSuper = ch.stream().map(JPNode::getNodeType).anyMatch(type -> type == ABLNodeType.SUPER);
boolean containsMap = ch.stream().map(JPNode::getNodeType).anyMatch(type -> type == ABLNodeType.MAP);
if (containsForward || containsSuper || containsMap) {
// Last child should be PERIOD
JPNode lastCh = ch.get(ch.size() - 1);
if (lastCh.getNodeType() != ABLNodeType.PERIOD) {
reportIssue(file, node, "FUNCTION declaration should end with a period", true);
}
} else {
// Last child should be PERIOD
JPNode lastCh = ch.get(ch.size() - 1);
JPNode lastCh2 = ch.get(ch.size() - 2);
if ((lastCh.getNodeType() != ABLNodeType.PERIOD) || (lastCh2.getNodeType() != ABLNodeType.END)) {
reportIssue(file, node, "FUNCTION declaration should end with END [FUNCTION] followed by a period", true);
}
}
}

private void handleMethodBlock(ParseUnit unit, InputFile file, JPNode node) {
List<JPNode> ch = node.getDirectChildren();
boolean containsAbstract = ch.stream().map(JPNode::getNodeType).anyMatch(type -> type == ABLNodeType.ABSTRACT);
JPNode lastCh = ch.get(ch.size() - 1);
if (unit.isInterface() || containsAbstract) {
if (lastCh.getNodeType() == ABLNodeType.LEXCOLON) {
NewIssue issue = createIssue(file, node, "METHOD prototype declaration...", true);
if (issue != null) {
addLocation(issue, file, lastCh, "... should end with a period and not a colon", true);
issue.save();
}
}
} else {
for (int zz = 1; zz < ch.size() - 1; zz++) {
if ((ch.get(zz).getNodeType() == ABLNodeType.PARAMETER_LIST)
&& (ch.get(zz + 1).getNodeType() == ABLNodeType.PERIOD)) {
NewIssue issue = createIssue(file, node, "METHOD block...", true);
if (issue != null) {
addLocation(issue, file, ch.get(zz + 1), "... should end with a colon and not a period", true);
issue.save();
}
}
}
}
}

private void handleDoBlock(InputFile file, JPNode node) {
List<JPNode> ch = node.getDirectChildren();
// Unlikely, but early exit just to be sure
if (ch.size() <= 1)
return;

// Last child should be PERIOD
JPNode lastCh = ch.get(ch.size() - 1);
JPNode lastCh2 = ch.get(ch.size() - 2);
if ((lastCh.getNodeType() != ABLNodeType.PERIOD) || (lastCh2.getNodeType() != ABLNodeType.END)) {
reportIssue(file, node, "Block should end with END [blockType] followed by a period", true);
}
}

private void handleStatement(InputFile file, JPNode node) {
if ((node.getNodeType() == ABLNodeType.IF) || (node.getNodeType() == ABLNodeType.WHEN)
|| (node.getNodeType() == ABLNodeType.OTHERWISE) || (node.getNodeType() == ABLNodeType.ON)
|| (node.getNodeType() == ABLNodeType.EXPR_STATEMENT))
return;
if ((node.getNodeType() == ABLNodeType.DEFINE) && node.isIStatement()
&& (node.asIStatement().getNodeType2() == ABLNodeType.PROPERTY))
return;
List<JPNode> ch = node.getDirectChildren();
// Unlikely, but early exit just to be sure
if (ch.size() < 1)
return;

// Last child should be PERIOD
JPNode lastCh = ch.get(ch.size() - 1);
if (lastCh.getNodeType() != ABLNodeType.PERIOD) {
reportIssue(file, node.firstNaturalChild(), "Statement should end with a period", true);
}
}

Expand Down
Loading

0 comments on commit 93e1c62

Please sign in to comment.