Method output
has a Cognitive Complexity of 227 (exceeds 5 allowed). Consider refactoring. Open
public ExecutionResult output(@NonNull List<String> variables,
Map<String, T> placeholderValues,
Map<String, SDValue> otherPlaceHolderValues,
MultiDataSet batch,
Collection<String> requiredActivations,
- Read upRead up
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 AbstractSession.java
has 857 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* ******************************************************************************
* *
* *
* * This program and the accompanying materials are made available under the
Method output
has 343 lines of code (exceeds 25 allowed). Consider refactoring. Open
public ExecutionResult output(@NonNull List<String> variables,
Map<String, T> placeholderValues,
Map<String, SDValue> otherPlaceHolderValues,
MultiDataSet batch,
Collection<String> requiredActivations,
Method updateDescendantDeps
has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring. Open
protected void updateDescendantDeps(ExecStep justExecuted, FrameIter outFrameIter) {
ExecType t = justExecuted.getType();
String n = justExecuted.getName();
if (justExecuted.getType() == ExecType.OP) {
SameDiffOp op = sameDiff.getOps().get(n);
- Read upRead up
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 initSubgraph
has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring. Open
protected void initSubgraph(Set<String> variables) {
// Step 1: determine subgraph structure we actually need to execute
Queue<String> processingQueue = new LinkedList<>(variables);
// Note subgraph initially should include placeholders and constants
- Read upRead up
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 getExecStepForVar
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
protected ExecStep getExecStepForVar(String varName, FrameIter frameIter) {
Variable v = sameDiff.getVariables().get(varName);
if (v == null) {
SameDiffOp op = sameDiff.getOps().get(varName);
if (op != null) {
- Read upRead up
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
AbstractSession
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
@Slf4j
public abstract class AbstractSession<T, O> {
/**
* All execution in Samediff happens in a frame... this is the name of the
Method getExecStepForVar
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected ExecStep getExecStepForVar(String varName, FrameIter frameIter) {
Variable v = sameDiff.getVariables().get(varName);
if (v == null) {
SameDiffOp op = sameDiff.getOps().get(varName);
if (op != null) {
Method initSubgraph
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void initSubgraph(Set<String> variables) {
// Step 1: determine subgraph structure we actually need to execute
Queue<String> processingQueue = new LinkedList<>(variables);
// Note subgraph initially should include placeholders and constants
Method getTensorArraysInSession
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public List<INDArray> getTensorArraysInSession(String name, String frame, int iteration, FrameIter parentFrame) {
DifferentialFunction op = sameDiff.getVariableOutputOp(name);
if (op == null)
return null;
String[] inputs = sameDiff.getInputsForOp(op);
- Read upRead up
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 updateDescendantDeps
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void updateDescendantDeps(ExecStep justExecuted, FrameIter outFrameIter) {
ExecType t = justExecuted.getType();
String n = justExecuted.getName();
if (justExecuted.getType() == ExecType.OP) {
SameDiffOp op = sameDiff.getOps().get(n);
Method addDependenciesForOp
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected void addDependenciesForOp(String opName, FrameIter depFrameIter) {
SameDiffOp op = sameDiff.getOps().get(opName);
List<String> inputs = op.getInputsToOp();
List<String> cdOps = op.getControlDeps();
List<String> cdVars = op.getVarControlDeps();
- Read upRead up
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 addDependenciesForOp
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void addDependenciesForOp(String opName, FrameIter depFrameIter) {
SameDiffOp op = sameDiff.getOps().get(opName);
List<String> inputs = op.getInputsToOp();
List<String> cdOps = op.getControlDeps();
List<String> cdVars = op.getVarControlDeps();
Method execFailed
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected void execFailed(Set<String> userRequestedUnique, Map<String, SDValue> out, Set<String> allRequired,
Set<String> allExecuted, int step) {
int missingCount = userRequestedUnique.size() - out.size();
StringBuilder sb = new StringBuilder();
sb.append("No variable are available for execution at step ")
- Read upRead up
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 getOutputs
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
public abstract ExecutionResult getOutputs(O op, FrameIter outputFrameIter, Set<VarId> inputs,
Set<VarId> allIterInputs, Set<String> constAndPhInputs,
List<Listener> listeners, At at, MultiDataSet batch, Set<String> allReqVariables,
Map<String, SDValue> otherPlaceHolders);
Method getTensorArraysInSession
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public List<INDArray> getTensorArraysInSession(String name, String frame, int iteration, FrameIter parentFrame) {
DifferentialFunction op = sameDiff.getVariableOutputOp(name);
if (op == null)
return null;
String[] inputs = sameDiff.getInputsForOp(op);
Method execFailed
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected void execFailed(Set<String> userRequestedUnique, Map<String, SDValue> out, Set<String> allRequired,
Set<String> allExecuted, int step) {
int missingCount = userRequestedUnique.size() - out.size();
StringBuilder sb = new StringBuilder();
sb.append("No variable are available for execution at step ")
Method getAndParameterizeOp
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public abstract O getAndParameterizeOp(String opName, FrameIter frameIter, Set<VarId> inputs,
Set<VarId> allIterInputs, Set<String> constAndPhInputs,
Map<String, T> placeholderValues, Set<String> allReqVariables, Map<String, SDValue> otherPlaceholders);
Method postProcessOutputValues
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected Map<String, SDValue> postProcessOutputValues(Map<String, SDValue> output) {
for (Map.Entry<String, SDValue> entry : output.entrySet()) {
switch (entry.getValue().getSdValueType()) {
case DICT:
for (Map.Entry<String, INDArray> arr : entry.getValue().getDictValue().entrySet()) {
- Read upRead up
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 output
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public ExecutionResult output(@NonNull List<String> variables,
Map<String, T> placeholderValues,
Map<String, SDValue> otherPlaceHolderValues,
MultiDataSet batch,
Collection<String> requiredActivations,
Avoid deeply nested control flow statements. Open
for (String s2 : v.getInputsForOp()) {
if (subgraph.contains(s2)) {
// Placeholder is required
required = true;
break;
Avoid deeply nested control flow statements. Open
if (!subgraph.contains(s)) {
processingQueue.add(s);
}
Avoid deeply nested control flow statements. Open
for (String opName : cdForOps) {
if (subgraphOps.contains(opName)) {
// We've just executed X, and there's dependency X -> Y
// But, there also might be a Z -> Y that we should mark as needed for Y
addDependenciesForOp(opName, outFrameIter);
Avoid deeply nested control flow statements. Open
if (!subgraph.contains(s2)) {
processingQueue.add(s2);
}
Method output
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public Map<String, T> output(@NonNull List<String> variables, Map<String, T> placeholderValues,
MultiDataSet batch, Collection<String> requiredActivations, List<Listener> listeners, At at) {
Avoid deeply nested control flow statements. Open
if (!subgraph.contains(s2)) {
processingQueue.add(s2);
}
Avoid deeply nested control flow statements. Open
for (String s : inputsToExecOp) {
if (inputOpOutNames.contains(s)) {
VarId vid = new VarId(s, dep.getFrameIter().getFrame(),
dep.getFrameIter().getIteration(),
dep.getFrameIter().getParentFrame());
Avoid deeply nested control flow statements. Open
if (op.getOp() instanceof Switch && inputNames.size() > 1
&& inputNames.get(0).equals(inputNames.get(1))) {
putNodeValue(sdValue, vid);
putNodeValue(sdValue, outFrameIter.toVarId(vid.getVariable() + ":1"));
} else {
Avoid deeply nested control flow statements. Open
if (e2.isConstant()) {
parentFrame.setIteration(0);
parentFrame = parentFrame.getParentFrame();
inVarName = sdo2.getInputsToOp().get(0);
} else {
Avoid deeply nested control flow statements. Open
for (String opName : inputsToOps) {
if (subgraphOps.contains(opName)) {
// We've just executed X, and there's dependency X -> Y
// But, there also might be a Z -> Y that we should mark as needed for Y
addDependenciesForOp(opName, outFrameIter);
Method execFailed
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected void execFailed(Set<String> userRequestedUnique, Map<String, SDValue> out, Set<String> allRequired,
Set<String> allExecuted, int step) {
Method get
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public SDValue get(String variable, String frame, int iteration, FrameIter parentFrameIter,
boolean enforceExistence) {
Method lookup
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected static VarId lookup(String name, Collection<VarId> varIds, Collection<VarId> varIds2,
boolean exceptionOnNotFound) {
VarId vid = varIds == null ? null : lookup(name, varIds, false);
if (vid == null && varIds2 != null)
vid = lookup(name, varIds2, false);
- Read upRead up
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
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return new ExecStep(ExecType.PLACEHOLDER, v.getVariable().name(), new FrameIter(OUTER_FRAME, 0, null));
Avoid too many return
statements within this method. Open
return new ExecStep(ExecType.VARIABLE, v.getVariable().name(), new FrameIter(OUTER_FRAME, 0, null));
Avoid too many return
statements within this method. Open
return new ExecStep(ExecType.CONSTANT, v.getVariable().name(), new FrameIter(OUTER_FRAME, 0, null));
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (v != null) {
List<String> inputsToOps = v.getInputsForOp();
if (inputsToOps != null) {
for (String opName : inputsToOps) {
if (subgraphOps.contains(opName)) {
- Read upRead up
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (v != null) {
List<String> inputsToOps = v.getInputsForOp();
if (inputsToOps != null) {
for (String opName : inputsToOps) {
if (subgraphOps.contains(opName)) {
- Read upRead up
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (left) {
branch = new ExecStep(ExecType.SWITCH_L, es.getName(), es.getFrameIter());
} else {
branch = new ExecStep(ExecType.SWITCH_R, es.getName(), es.getFrameIter());
}
- Read upRead up
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 48.
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 (left) {
branch = new ExecStep(ExecType.SWITCH_L, es.getName(), es.getFrameIter());
} else {
branch = new ExecStep(ExecType.SWITCH_R, es.getName(), es.getFrameIter());
}
- Read upRead up
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 48.
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