-
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
78 changed files
with
1,052 additions
and
477 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
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
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
61 changes: 61 additions & 0 deletions
61
esql-checks/src/main/java/com/exxeta/iss/sonar/esql/check/TrailingWhitespaceCheck.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,61 @@ | ||
/* | ||
* Sonar ESQL Plugin | ||
* Copyright (C) 2013-2018 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 java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.regex.Pattern; | ||
|
||
import org.sonar.check.Rule; | ||
|
||
import com.exxeta.iss.sonar.esql.api.tree.Tree; | ||
import com.exxeta.iss.sonar.esql.api.visitors.EsqlFile; | ||
import com.exxeta.iss.sonar.esql.api.visitors.LineIssue; | ||
import com.exxeta.iss.sonar.esql.api.visitors.SubscriptionVisitorCheck; | ||
import com.exxeta.iss.sonar.esql.lexer.EsqlLexer; | ||
|
||
|
||
@Rule(key = "TrailingWhitespace") | ||
public class TrailingWhitespaceCheck extends SubscriptionVisitorCheck { | ||
|
||
private static final String MESSAGE = "Remove the useless trailing whitespaces at the end of this line."; | ||
|
||
@Override | ||
public Set<Tree.Kind> nodesToVisit() { | ||
return Collections.emptySet(); | ||
} | ||
|
||
@Override | ||
public void visitFile(Tree scriptTree) { | ||
EsqlFile javaScriptFile = getContext().getEsqlFile(); | ||
List<String> lines = CheckUtils.readLines(javaScriptFile); | ||
|
||
for (int i = 0; i < lines.size(); i++) { | ||
String line = lines.get(i); | ||
|
||
if (line.length() > 0 && Pattern.matches("[" + EsqlLexer.WHITESPACE + "]", line.subSequence(line.length() - 1, line.length()))) { | ||
addIssue(new LineIssue(this, i + 1, MESSAGE)); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
} |
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
10 changes: 10 additions & 0 deletions
10
esql-checks/src/main/resources/org/sonar/l10n/esql/rules/esql/TrailingWhitespace.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,10 @@ | ||
<p>Trailing whitespaces are simply useless and should not stay in code. They may generate noise when comparing different versions of the same | ||
file.</p> | ||
<p>If you encounter issues from this rule, this probably means that you are not using an automated code formatter - which you should if you have the | ||
opportunity to do so. </p> | ||
<h2>Noncompliant Code Example</h2> | ||
<pre> | ||
-- The following string will error if there is a whitespace after '\' | ||
SET str = 'Hello \ | ||
World'; | ||
</pre> |
15 changes: 15 additions & 0 deletions
15
esql-checks/src/main/resources/org/sonar/l10n/esql/rules/esql/TrailingWhitespace.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,15 @@ | ||
{ | ||
"title": "Lines should not end with trailing whitespaces", | ||
"type": "CODE_SMELL", | ||
"status": "ready", | ||
"remediation": { | ||
"func": "Constant\/Issue", | ||
"constantCost": "1min" | ||
}, | ||
"tags": [ | ||
"convention" | ||
], | ||
"defaultSeverity": "Minor", | ||
"ruleSpecification": "RSPEC-1131", | ||
"sqKey": "S1131" | ||
} |
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
Oops, something went wrong.