File Analyzer.js
has 808 lines of code (exceeds 250 allowed). Consider refactoring. Open
// global
var fs = require("fs");
var Chalk = require("chalk");
var ut = require("./Utils.js");
Function mapInstructionFrom
has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring. Open
function mapInstructionFrom(method, data, stats){
let bb = null, instruct = null, obj = null, x = null, success=false, stmt=null, tmp=null, t=0,t1=0;
if(! method instanceof CLASS.Method){
Logger.error("[!] mapping failed : method provided is not an instance of Method.");
- 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
Function MakeMap
has 159 lines of code (exceeds 25 allowed). Consider refactoring. Open
function MakeMap(data,absoluteDB){
Logger.raw("\n[*] Start object mapping ...\n------------------------------------------");
let step = data.classes.size(), /*data.classesCtr,*/ g=0;
let overrided = [];
Function mapInstructionFrom
has 121 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mapInstructionFrom(method, data, stats){
let bb = null, instruct = null, obj = null, x = null, success=false, stmt=null, tmp=null, t=0,t1=0;
if(! method instanceof CLASS.Method){
Logger.error("[!] mapping failed : method provided is not an instance of Method.");
Function Analyzer
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Analyzer(encoding, finder, ctx=null){
SmaliParser.setContext(ctx);
var db = this.db = new AnalyzerDatabase(ctx);
Function showCFG
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.showCFG = function(bblocks, offset=0, prefix="", fn=null){
if(bblocks.length==0 || bblocks[offset]==undefined){
Logger.debug(offset+" => not block");
return 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
Function makeTree
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Analyzer.prototype.makeTree = function(bblocks){
let last = {};
for(let i=0; i<bblocks.length; i++){
bblocks[i].offset = i;
if(bblocks[i].stack.length > 0){
Function resolveInheritedField
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function resolveInheritedField(fieldRef, parentClass){
for(let i in parentClass.fields){
if(parentClass.fields[i].name===fieldRef.name){
if(parentClass.fields[i].tags.indexOf('missing')>-1){
return parentClass.fields[i];
- 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
Function resolveInheritedMethod
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function resolveInheritedMethod(methodRef, parentClass){
for(let i in parentClass.methods){
if(parentClass.methods[i].name===methodRef.name){
if(parentClass.methods[i].tags.indexOf('missing')>-1){
return parentClass.methods[i];
- 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
Function showCFG_old
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.showCFG_old = function(bblocks, prefix=""){
let pathTRUE = Chalk.green(prefix+" |\n"+prefix+" |\n"+prefix+" |\n"+prefix+" +-----[TRUE]-->");
let path_len = " +-----[TRUE]-->".length;
let pathFALSE = Chalk.red(prefix+" |\n"+prefix+" |\n"+prefix+" |\n"+prefix+" +-----[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
Function showCFG
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Analyzer.prototype.showCFG = function(bblocks, offset=0, prefix="", fn=null){
if(bblocks.length==0 || bblocks[offset]==undefined){
Logger.debug(offset+" => not block");
return null;
Function makeTree
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.makeTree = function(bblocks){
let last = {};
for(let i=0; i<bblocks.length; i++){
bblocks[i].offset = i;
if(bblocks[i].stack.length > 0){
- 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
Function method
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
method: function(db, methRef, isStaticCall){
let meth = db.methods.getEntry(methRef.signature());
// 1. search into indexed method
Function showCFG_old
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Analyzer.prototype.showCFG_old = function(bblocks, prefix=""){
let pathTRUE = Chalk.green(prefix+" |\n"+prefix+" |\n"+prefix+" |\n"+prefix+" +-----[TRUE]-->");
let path_len = " +-----[TRUE]-->".length;
let pathFALSE = Chalk.red(prefix+" |\n"+prefix+" |\n"+prefix+" |\n"+prefix+" +-----[FALSE]->");
Function findBasicBlocks
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Analyzer.prototype.findBasicBlocks = function(instr){
let bblocks = [], blk={};
blk = {stack:[], next:[], label:null };
for(let i in instr){
Function findBasicBlocks
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.findBasicBlocks = function(instr){
let bblocks = [], blk={};
blk = {stack:[], next:[], label:null };
for(let i in instr){
- 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
Function flattening
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.flattening = function(method){
let instr = [], meta={};
for(let i in method.instr){
meta = {
label: (method.instr[i].tag !== null)? method.instr[i].tag : 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
Avoid deeply nested control flow statements. Open
if(instruct.isSetter()){
instruct.right.addSetter(method);
}else{
instruct.right.addGetter(method);
}
Avoid deeply nested control flow statements. Open
else if(instruct.isUsingString()){
// add USAGE: NEW/READ/WRITE
data.strings.insert(new CLASS.StringValue({
Avoid deeply nested control flow statements. Open
if(method._useClass[instruct.right.fqcn] == undefined){
method._useClass[instruct.right.fqcn] = [];
method._useClassCtr++;
}
Avoid deeply nested control flow statements. Open
if(instruct.right === undefined || instruct.right._callers === undefined){
Logger.debug("[SAST] Call : method cannot be resolved : ", instruct);
}
Function method
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
method: function(db, methRef, isStaticCall){
let meth = db.methods.getEntry(methRef.signature());
// 1. search into indexed method
- 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 deeply nested control flow statements. Open
if(t !==null)
stmt[j].setTarget(t);
else{
Logger.error("Target catch block not found");
console.log( stmt[j].getTarget());
Avoid deeply nested control flow statements. Open
if(instruct.right == null){
Logger.debug("[SAST] Call : method name is null");
}
Avoid deeply nested control flow statements. Open
if(method._useField[instruct.right.signature()] == undefined){
method._useField[instruct.right.signature()] = [];
method._useFieldCtr++;
}
Function field
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
field: function(db, fieldRef){
let field = db.fields.getEntry(fieldRef.signature());
if(field instanceof CLASS.Field){
- 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 function. Open
return createMissingField( fieldRef, cls, db);
Function useSyscalls
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.useSyscalls = function(syscalls){
//this.db.syscalls = {};
for(let i=0; i<syscalls.length ; i++){
for(let j=0; j<syscalls[i].sysnum.length; j++){
if(syscalls[i].sysnum[j]>-1){
- 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
Function Analyzer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function Analyzer(encoding, finder, ctx=null){
SmaliParser.setContext(ctx);
var db = this.db = new AnalyzerDatabase(ctx);
- 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
Function type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
type: function(db, fqcn){
if(fqcn instanceof CLASS.Class){
if(db.classes.hasEntry(fqcn.fqcn)===true)
return db.classes.getEntry(fqcn.fqcn);
- 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
Function insertIn
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Analyzer.prototype.insertIn = function(category, inData){
if(inData instanceof Array){
for(let i=0; i<inData.length; i++){
this.db[category].insert(inData[i]);
}
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
function resolveInheritedMethod(methodRef, parentClass){
for(let i in parentClass.methods){
if(parentClass.methods[i].name===methodRef.name){
if(parentClass.methods[i].tags.indexOf('missing')>-1){
return parentClass.methods[i];
- 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 215.
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
function resolveInheritedField(fieldRef, parentClass){
for(let i in parentClass.fields){
if(parentClass.fields[i].name===fieldRef.name){
if(parentClass.fields[i].tags.indexOf('missing')>-1){
return parentClass.fields[i];
- 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 215.
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
case CONST.BRANCH.IF_TRUE:
Logger.info(prefix+Chalk.bold.green("if TRUE :"));
this.showBlock(bblocks[i].next[j].block, prefix, Chalk.green);
break;
- 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 73.
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
case CONST.BRANCH.IF_FALSE:
Logger.info(prefix+Chalk.bold.red("if FALSE :"));
this.showBlock(bblocks[i].next[j].block, prefix, Chalk.red);
break;
- 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 73.
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(method._useField[instruct.right.signature()] == undefined){
method._useField[instruct.right.signature()] = [];
method._useFieldCtr++;
}
- 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 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if(method._useMethod[instruct.right.signature()] == undefined){
method._useMethod[instruct.right.signature()] = [];
method._useMethodCtr++;
}
- 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 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if(cls.extends !== null){
field = resolveInheritedField(fieldRef, cls.extends);
if(field instanceof CLASS.Field){
cls.addInheritedField(fieldRef, field);
- 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 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if(cls.extends instanceof CLASS.Class){
meth = resolveInheritedMethod(methRef, cls.extends);
if(meth instanceof CLASS.Method){
cls.addInheritedMethod(methRef, meth);
- 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 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