Aufgrund einer Wartung wird GitLab am 25.01 zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 25.01 between 8:00 and 9:00 am.

Commit 258453cc authored by Christoph Richter's avatar Christoph Richter
Browse files

MathCommandRegister: Decreased cognitive complexity of isTargetLanguageCommand

parent 27152df8
...@@ -46,7 +46,17 @@ public abstract class MathCommand { ...@@ -46,7 +46,17 @@ public abstract class MathCommand {
* *
* @return targetLanguageCommandName * @return targetLanguageCommandName
*/ */
public HashSet<String> getTargetLanguageCommandNames() { protected HashSet<String> getTargetLanguageCommandNames() {
return targetLanguageCommandNames; return targetLanguageCommandNames;
} }
public boolean isTargetLanguageCommand(String command) {
if (!command.isEmpty())
for (String s : getTargetLanguageCommandNames())
if (s.contains(command))
return true;
return false;
}
} }
...@@ -27,21 +27,18 @@ public abstract class MathCommandRegister { ...@@ -27,21 +27,18 @@ public abstract class MathCommandRegister {
public boolean isMathCommand(String functionName) { public boolean isMathCommand(String functionName) {
boolean isMathCommand = false; boolean isMathCommand = false;
if (!functionName.isEmpty()) { if (getMathCommand(functionName) != null) {
if (getMathCommand(functionName) != null) { isMathCommand = true;
isMathCommand = true; } else {
} else { isMathCommand = isTargetLanguageCommand(functionName);
isMathCommand = isTargetLanguageCommand(functionName);
}
} }
return isMathCommand; return isMathCommand;
} }
private boolean isTargetLanguageCommand(String command) { private boolean isTargetLanguageCommand(String command) {
for (MathCommand mathCommand : mathCommands) for (MathCommand mathCommand : mathCommands)
for (String s : mathCommand.getTargetLanguageCommandNames()) if (mathCommand.isTargetLanguageCommand(command))
if (s.contains(command)) return true;
return true;
return false; return false;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment