Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2015-10-15 06:20:50 -0400
committerAlexander Kurtakov2015-10-15 06:20:50 -0400
commit1921421f953b079ba83048a84ff99f7bd96c235d (patch)
tree2d752cf3661c2afc80ebd4303583f1393fe642c1
parent0fd7ff52a295c37f318975ff6caa29a6fc109987 (diff)
downloadorg.eclipse.dltk.sh-1921421f953b079ba83048a84ff99f7bd96c235d.tar.gz
org.eclipse.dltk.sh-1921421f953b079ba83048a84ff99f7bd96c235d.tar.xz
org.eclipse.dltk.sh-1921421f953b079ba83048a84ff99f7bd96c235d.zip
sh: Fix sonar warnings.
* Combine if statements. * Use {} around blocks. Change-Id: I45a18f0451f8f5e91e2a9644e1dc1eb366dcb1d6 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/internal/core/parser/ShellScriptSourceParser.java11
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/DollarBraceCountingRule.java4
-rw-r--r--plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/folding/ShellCodeFoldingBlockProvider.java6
3 files changed, 7 insertions, 14 deletions
diff --git a/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/internal/core/parser/ShellScriptSourceParser.java b/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/internal/core/parser/ShellScriptSourceParser.java
index 2a9da3f..9fbb004 100644
--- a/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/internal/core/parser/ShellScriptSourceParser.java
+++ b/plugins/org.eclipse.dltk.sh.core/src/org/eclipse/dltk/sh/internal/core/parser/ShellScriptSourceParser.java
@@ -76,13 +76,9 @@ public class ShellScriptSourceParser extends AbstractSourceParser {
functionNames.add(line.substring(fPlusEight, lBracket).trim());
tmp.push(mDeclaration);
model.addFunction(mDeclaration);
- } else if (line.trim().equals("}")) {
- if (mDeclaration != null) {
- if (!tmp.isEmpty()) {
- mDeclaration = (MethodDeclaration) tmp.pop();
- mDeclaration.setEnd(lineStart + line.length());
- }
- }
+ } else if (line.trim().equals("}") && mDeclaration != null && !tmp.isEmpty()) {
+ mDeclaration = (MethodDeclaration) tmp.pop();
+ mDeclaration.setEnd(lineStart + line.length());
}
Pattern assignmentPattern = Pattern.compile("(^|\\W)\\w*=");
Matcher matcher = assignmentPattern.matcher(line);
@@ -198,7 +194,6 @@ public class ShellScriptSourceParser extends AbstractSourceParser {
lineStart += line.length() + commentLength + 1;
commentLength = 0;
}
- bReader.close();
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/DollarBraceCountingRule.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/DollarBraceCountingRule.java
index f9adede..dac3543 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/DollarBraceCountingRule.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/DollarBraceCountingRule.java
@@ -86,9 +86,9 @@ public class DollarBraceCountingRule extends PatternRule {
break;
}
}
- } else
+ } else {
scanner.read();
-
+ }
} else if (c == fOpening) {
// Count opening braces
fBraceCount++;
diff --git a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/folding/ShellCodeFoldingBlockProvider.java b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/folding/ShellCodeFoldingBlockProvider.java
index ba9f1af..9ffb9c1 100644
--- a/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/folding/ShellCodeFoldingBlockProvider.java
+++ b/plugins/org.eclipse.dltk.sh.ui/src/org/eclipse/dltk/sh/internal/ui/text/folding/ShellCodeFoldingBlockProvider.java
@@ -45,10 +45,8 @@ public class ShellCodeFoldingBlockProvider extends ModelFoldingBlockProvider {
@Override
protected boolean isFoldedInitially(IModelElement element) {
- if (foldingEnabled) {
- if (element instanceof IMethod) {
- return functionsCollapsedInitially;
- }
+ if (foldingEnabled && (element instanceof IMethod)) {
+ return functionsCollapsedInitially;
}
return false;
}

Back to the top