Method generateJoinerRelationAdvanced
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
public static List<JoinRelationAdvanced> generateJoinerRelationAdvanced(FskPortObject portObject,
LinkedHashMap<String, Object[]> originalNamesMap, List<Parameter> topLevelJoinedModelParams, List<JoinRelation> joinRelations,
AtomicInteger index, List<JoinRelationAdvanced> joinRelationList, LinkedHashMap<String, String> ModelsToSuffixMap, List<JoinRelation> foundRelation) {
if (joinRelationList == null) {
joinRelationList = new ArrayList<>();
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File JoinerNodeUtil.java
has 422 lines of code (exceeds 250 allowed). Consider refactoring. Open
package de.bund.bfr.knime.fsklab.v2_0.joiner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
- Create a ticketCreate a ticket
Method generateColorMap
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static LinkedHashMap<String, Object[]> generateColorMap(FskPortObject portObject,
LinkedHashMap<String, Object[]> originalNamesMap, List<Parameter> topLevelJoinedModelParams,
AtomicInteger index, AtomicInteger generatedColorInt) {
if (originalNamesMap == null) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method createAllPossibleSimulations
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static void createAllPossibleSimulations(FskPortObject firstFskObj,
FskPortObject secondFskObj, CombinedFskPortObject outObj) {
int indexFirst = 0;
int indexSecond = 0;
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method generateJoinerRelationAdvanced
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static List<JoinRelationAdvanced> generateJoinerRelationAdvanced(FskPortObject portObject,
LinkedHashMap<String, Object[]> originalNamesMap, List<Parameter> topLevelJoinedModelParams, List<JoinRelation> joinRelations,
AtomicInteger index, List<JoinRelationAdvanced> joinRelationList, LinkedHashMap<String, String> ModelsToSuffixMap, List<JoinRelation> foundRelation) {
if (joinRelationList == null) {
joinRelationList = new ArrayList<>();
- Create a ticketCreate a ticket
Method removeJoinedParameters
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static void removeJoinedParameters(JoinRelation[] relations, FskPortObject outfskPort) {
if (outfskPort instanceof CombinedFskPortObject) {
if (relations != null)
for (JoinRelation relation : relations) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addIdentifierToParametersForCombinedObject
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static void addIdentifierToParametersForCombinedObject(FskPortObject portObject,
String suffix, int suffixInsertionIndex,
final Map<String, List<String>> unModifiedParamsNames,
Map<String, Map<String, String>> old_new_pramsMap)
throws JsonMappingException, JsonProcessingException {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getTopLevelParameterNames
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static LinkedHashMap<String, String> getTopLevelParameterNames(FskPortObject portObject,
LinkedHashMap<String, String> toplevelOutputParameters,
LinkedHashMap<String, String> originalNamesMap, String suffix) {
if (originalNamesMap == null) {
originalNamesMap = new LinkedHashMap<String, String>();
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method findSuffix
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static String findSuffix(List<String> listOfParameter) {
List<String> trailingNums = extractNumber(listOfParameter);
int longestStringIndex = 0;
int longestString = 0;
for(int x = 0; x < trailingNums.size(); x++) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method generateColorMap
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static LinkedHashMap<String, Object[]> generateColorMap(FskPortObject portObject,
LinkedHashMap<String, Object[]> originalNamesMap, List<Parameter> topLevelJoinedModelParams,
AtomicInteger index, AtomicInteger generatedColorInt) {
if (originalNamesMap == null) {
- Create a ticketCreate a ticket
Method adaptRelationNames
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static void adaptRelationNames(CombinedFskPortObject portObject, String suffix, int suffixInsertionIndex,
Map<String, String> old_new_pramsMap) {
Map<String, String> mapInversed = old_new_pramsMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey,
// choose the second value in the case of key duplication
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method adaptRelationNames
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void adaptRelationNames(CombinedFskPortObject portObject, String suffix, int suffixInsertionIndex,
Map<String, String> old_new_pramsMap) {
Map<String, String> mapInversed = old_new_pramsMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey,
// choose the second value in the case of key duplication
- Create a ticketCreate a ticket
Method addIdentifierToParametersForCombinedObject
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void addIdentifierToParametersForCombinedObject(FskPortObject portObject,
String suffix, int suffixInsertionIndex,
final Map<String, List<String>> unModifiedParamsNames,
Map<String, Map<String, String>> old_new_pramsMap)
throws JsonMappingException, JsonProcessingException {
- Create a ticketCreate a ticket
Method createAllPossibleSimulations
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void createAllPossibleSimulations(FskPortObject firstFskObj,
FskPortObject secondFskObj, CombinedFskPortObject outObj) {
int indexFirst = 0;
int indexSecond = 0;
- Create a ticketCreate a ticket
Method findSuffix
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static String findSuffix(List<String> listOfParameter) {
List<String> trailingNums = extractNumber(listOfParameter);
int longestStringIndex = 0;
int longestString = 0;
for(int x = 0; x < trailingNums.size(); x++) {
- Create a ticketCreate a ticket
Method generateJoinerRelationAdvanced
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public static List<JoinRelationAdvanced> generateJoinerRelationAdvanced(FskPortObject portObject,
LinkedHashMap<String, Object[]> originalNamesMap, List<Parameter> topLevelJoinedModelParams, List<JoinRelation> joinRelations,
AtomicInteger index, List<JoinRelationAdvanced> joinRelationList, LinkedHashMap<String, String> ModelsToSuffixMap, List<JoinRelation> foundRelation) {
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (b2)
iter.remove();
- Create a ticketCreate a ticket
Method addIdentifierToParametersForCombinedObject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static void addIdentifierToParametersForCombinedObject(FskPortObject portObject,
String suffix, int suffixInsertionIndex,
final Map<String, List<String>> unModifiedParamsNames,
Map<String, Map<String, String>> old_new_pramsMap)
- Create a ticketCreate a ticket
Method addIdentifierToParametersAndStoreInMap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private static void addIdentifierToParametersAndStoreInMap(FskPortObject portObject,
String suffix, int suffixInsertionIndex,
final Map<String, List<String>> unModifiedParamsNames,
Map<String, Map<String, String>> old_new_pramsMap) {
- Create a ticketCreate a ticket
Method generateColorMap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static LinkedHashMap<String, Object[]> generateColorMap(FskPortObject portObject,
LinkedHashMap<String, Object[]> originalNamesMap, List<Parameter> topLevelJoinedModelParams,
AtomicInteger index, AtomicInteger generatedColorInt) {
- Create a ticketCreate a ticket
Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. Open
public static void createAllPossibleSimulations(FskPortObject firstFskObj,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.
See
Refactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed. Open
public static LinkedHashMap<String, Object[]> generateColorMap(FskPortObject portObject,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.
See
Refactor this method to reduce its Cognitive Complexity from 42 to the 15 allowed. Open
public static List<JoinRelationAdvanced> generateJoinerRelationAdvanced(FskPortObject portObject,
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.
See
Save and re-use this "Random". Open
Random r = new Random();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Creating a new Random
object each time a random value is needed is inefficient and may produce numbers which are not random depending
on the JDK. For better efficiency and randomness, create a single Random
, then store, and reuse it.
The Random()
constructor tries to set the seed with a distinct value every time. However there is no guarantee that the seed will be
random or even uniformly distributed. Some JDK will use the current time as seed, which makes the generated numbers not random at all.
This rule finds cases where a new Random
is created each time a method is invoked and assigned to a local random variable.
Noncompliant Code Example
public void doSomethingCommon() { Random rand = new Random(); // Noncompliant; new instance created with each invocation int rValue = rand.nextInt(); //...
Compliant Solution
private Random rand = SecureRandom.getInstanceStrong(); // SecureRandom is preferred to Random public void doSomethingCommon() { int rValue = this.rand.nextInt(); //...
Exceptions
A class which uses a Random
in its constructor or in a static main
function and nowhere else will be ignored by this
rule.
See
- OWASP Top 10 2017 Category A6 - Security Misconfiguration
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static void createAllPossibleSimulations(FskPortObject firstFskObj,
FskPortObject secondFskObj, CombinedFskPortObject outObj) {
int indexFirst = 0;
int indexSecond = 0;
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 262.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (outfskPort instanceof CombinedFskPortObject) {
if (relations != null)
for (JoinRelation relation : relations) {
Iterator<Parameter> iter = SwaggerUtil.getParameter(outfskPort.modelMetadata).iterator();
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 79.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static void createDefaultSimulation(FskPortObject fskObj) {
if (SwaggerUtil.getModelMath(fskObj.modelMetadata) != null) {
List<Parameter> combinedModelParameters = SwaggerUtil.getParameter(fskObj.modelMetadata);
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 66.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static FskSimulation makeIndividualSimulation(FskSimulation combinedSim, String suffix) {
FskSimulation fskSimulation = new FskSimulation(combinedSim.getName());
combinedSim.getParameters().forEach((pId, pValue) -> {
if (pId.endsWith(suffix))
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 65.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (portObject instanceof CombinedFskPortObject) {
originalNamesMap =
getTopLevelParameterNames(((CombinedFskPortObject) portObject).getFirstFskPortObject(),
toplevelOutputParameters, originalNamesMap, suffix + JoinerNodeModel.SUFFIX_FIRST);
originalNamesMap =
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static void saveOutputVariable(Map<String, String> originalOutputParameters,
ScriptHandler handler, ExecutionContext exec) {
// save output to the official name (with all the suffixes) so it doesn't get overwritten by
- Read upRead up
- Create a ticketCreate a ticket
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76