commit | 1921421f953b079ba83048a84ff99f7bd96c235d | [log] [tgz] |
---|---|---|
author | Alexander Kurtakov <akurtako@redhat.com> | Thu Oct 15 13:20:50 2015 +0300 |
committer | Alexander Kurtakov <akurtako@redhat.com> | Thu Oct 15 13:20:50 2015 +0300 |
tree | 2d752cf3661c2afc80ebd4303583f1393fe642c1 | |
parent | 0fd7ff52a295c37f318975ff6caa29a6fc109987 [diff] |
sh: Fix sonar warnings. * Combine if statements. * Use {} around blocks. Change-Id: I45a18f0451f8f5e91e2a9644e1dc1eb366dcb1d6 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
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 @@ 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 @@ 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 @@ 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 @@ @Override protected boolean isFoldedInitially(IModelElement element) { - if (foldingEnabled) { - if (element instanceof IMethod) { - return functionsCollapsedInitially; - } + if (foldingEnabled && (element instanceof IMethod)) { + return functionsCollapsedInitially; } return false; }