-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
509 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
esql-checks/src/main/java/com/exxeta/iss/sonar/esql/check/CommitCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Sonar ESQL Plugin | ||
* Copyright (C) 2013-2023 Thomas Pohl and EXXETA AG | ||
* http://www.exxeta.com | ||
* | ||
* Licensed 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 com.exxeta.iss.sonar.esql.check; | ||
|
||
import com.exxeta.iss.sonar.esql.api.visitors.DoubleDispatchVisitorCheck; | ||
import com.exxeta.iss.sonar.esql.tree.impl.statement.CommitStatementTreeImpl; | ||
import org.sonar.check.Rule; | ||
|
||
@Rule(key="Commit") | ||
public class CommitCheck extends DoubleDispatchVisitorCheck { | ||
|
||
public static final String MESSAGE = "COMMIT should not be called explicitly. Otherwise the messageflow can't handle the transaction."; | ||
@Override | ||
public void visitCommitStatement(CommitStatementTreeImpl tree) { | ||
addIssue(tree.commitKeyword(), MESSAGE); | ||
super.visitCommitStatement(tree); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
esql-checks/src/main/java/com/exxeta/iss/sonar/esql/check/RollbackCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Sonar ESQL Plugin | ||
* Copyright (C) 2013-2023 Thomas Pohl and EXXETA AG | ||
* http://www.exxeta.com | ||
* | ||
* Licensed 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 com.exxeta.iss.sonar.esql.check; | ||
|
||
import com.exxeta.iss.sonar.esql.api.visitors.DoubleDispatchVisitorCheck; | ||
import com.exxeta.iss.sonar.esql.tree.impl.statement.RollbackStatementTreeImpl; | ||
import org.sonar.check.Rule; | ||
|
||
@Rule(key="Rollback") | ||
public class RollbackCheck extends DoubleDispatchVisitorCheck { | ||
|
||
public static final String MESSAGE = "ROLLBACK should not be called explicitly. Otherwise the messageflow can't handle the transaction."; | ||
@Override | ||
public void visitRollbackStatement(RollbackStatementTreeImpl tree) { | ||
addIssue(tree.rollbackKeyword(), MESSAGE); | ||
super.visitRollbackStatement(tree); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
esql-checks/src/main/resources/org/sonar/l10n/esql/rules/esql/Commit.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<p>Avoid using the COMMIT statement in ESQL code, as it can undermine the transaction | ||
handling mechanism of the message flow. Instead, consider restructuring the flow | ||
to handle smaller transactions or committing all changes at once. This approach | ||
helps ensure that the transaction handling mechanism operates correctly and reliably, | ||
without risking unexpected behavior or data loss. By avoiding the use of COMMIT statements, | ||
you can help maintain the integrity and consistency of the message flow's data.</p> |
13 changes: 13 additions & 0 deletions
13
esql-checks/src/main/resources/org/sonar/l10n/esql/rules/esql/Commit.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"title": "COMMIT should not be used.", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "20min" | ||
}, | ||
"tags": [ | ||
"bad-practice" | ||
], | ||
"defaultSeverity": "Major" | ||
} |
5 changes: 5 additions & 0 deletions
5
esql-checks/src/main/resources/org/sonar/l10n/esql/rules/esql/Rollback.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p>Avoid using the ROLLBACK statement in ESQL code, as it can undermine the transaction | ||
handling mechanism of the message flow. Instead, consider using the THROW statement to | ||
raise an exception and trigger a rollback of the entire message flow. This approach helps | ||
ensure that the transaction handling mechanism operates correctly and reliably, without | ||
risking unexpected behavior or data loss.</p> |
13 changes: 13 additions & 0 deletions
13
esql-checks/src/main/resources/org/sonar/l10n/esql/rules/esql/Rollback.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"title": "ROLLBACK should not be used.", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "20min" | ||
}, | ||
"tags": [ | ||
"bad-practice" | ||
], | ||
"defaultSeverity": "Major" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
esql-checks/src/test/java/com/exxeta/iss/sonar/esql/check/CommitCheckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.exxeta.iss.sonar.esql.check; | ||
|
||
import com.exxeta.iss.sonar.esql.checks.verifier.EsqlCheckVerifier; | ||
import java.io.File; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class CommitCheckTest { | ||
|
||
@Test | ||
void test() { | ||
|
||
EsqlCheckVerifier.issues(new RollbackCheck(), new File("src/test/resources/commitRollback.esql")) | ||
.next().atLine(5).withMessage("ROLLBACK should not be called explicitly. Otherwise the messageflow can't handle the transaction.") | ||
.noMore(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
esql-checks/src/test/java/com/exxeta/iss/sonar/esql/check/RollbackCheckTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.exxeta.iss.sonar.esql.check; | ||
|
||
import com.exxeta.iss.sonar.esql.checks.verifier.EsqlCheckVerifier; | ||
import java.io.File; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class RollbackCheckTest { | ||
|
||
@Test | ||
void test() { | ||
|
||
EsqlCheckVerifier.issues(new CommitCheck(), new File("src/test/resources/commitRollback.esql")) | ||
.next().atLine(6).withMessage("COMMIT should not be called explicitly. Otherwise the messageflow can't handle the transaction.") | ||
.noMore(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE COMPUTE MODULE CommitRollback | ||
|
||
CREATE FUNCTION Main() RETURNS BOOLEAN | ||
BEGIN | ||
ROLLBACK; | ||
COMMIT; | ||
END; | ||
|
||
END MODULE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ntend/src/main/java/com/exxeta/iss/sonar/esql/api/tree/statement/CommitStatementTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Sonar ESQL Plugin | ||
* Copyright (C) 2013-2023 Thomas Pohl and EXXETA AG | ||
* http://www.exxeta.com | ||
* | ||
* Licensed 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 com.exxeta.iss.sonar.esql.api.tree.statement; | ||
|
||
import com.exxeta.iss.sonar.esql.api.tree.FieldReferenceTree; | ||
import com.exxeta.iss.sonar.esql.api.tree.lexical.SyntaxToken; | ||
|
||
public interface CommitStatementTree extends StatementTree{ | ||
|
||
SyntaxToken commitKeyword(); | ||
FieldReferenceTree databaseReference(); | ||
SyntaxToken semi(); | ||
} |
28 changes: 28 additions & 0 deletions
28
...end/src/main/java/com/exxeta/iss/sonar/esql/api/tree/statement/RollbackStatementTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Sonar ESQL Plugin | ||
* Copyright (C) 2013-2023 Thomas Pohl and EXXETA AG | ||
* http://www.exxeta.com | ||
* | ||
* Licensed 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 com.exxeta.iss.sonar.esql.api.tree.statement; | ||
|
||
import com.exxeta.iss.sonar.esql.api.tree.FieldReferenceTree; | ||
import com.exxeta.iss.sonar.esql.api.tree.lexical.SyntaxToken; | ||
|
||
public interface RollbackStatementTree extends StatementTree{ | ||
|
||
SyntaxToken rollbackKeyword(); | ||
FieldReferenceTree databaseReference(); | ||
SyntaxToken semi(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.