File index.js
has 738 lines of code (exceeds 250 allowed). Consider refactoring. Open
const OS = require("os");
const debug = require("debug")("debug-utils");
const util = require("util");
const Codec = require("@truffle/codec");
const BN = require("bn.js");
Function formatStacktrace
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
formatStacktrace: function (stacktrace, indent = 2) {
//get message or panic code from stacktrace
const { message, panic, custom } = stacktrace[0];
//we want to print inner to outer, so first, let's
//reverse
- 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 formatStacktrace
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
formatStacktrace: function (stacktrace, indent = 2) {
//get message or panic code from stacktrace
const { message, panic, custom } = stacktrace[0];
//we want to print inner to outer, so first, let's
//reverse
Function isUsableCompilation
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
isUsableCompilation: function (compilation) {
//check #1: is the source order reliable?
if (compilation.unreliableSourceOrder) {
debug("unreliable source order");
return 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
DebugUtils
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
var DebugUtils = {
truffleColors, //make these externally available
//panicCode may be either a number, BN, or decimal string
panicString: function (panicCode, verbose = false) {
Function isUsableCompilation
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
isUsableCompilation: function (compilation) {
//check #1: is the source order reliable?
if (compilation.unreliableSourceOrder) {
debug("unreliable source order");
return false;
Function formatCalldata
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
formatCalldata: function (calldata) {
//takes a Uint8Array
let selector = calldata.slice(0, Codec.Evm.Utils.SELECTOR_SIZE);
let words = [];
for (
Function formatRangeLines
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
formatRangeLines: function (
source,
range,
uncolorizedSource,
contextBefore = 2,
Function formatHelp
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
formatHelp: function (lastCommand = "n") {
var prefix = [
"Commands:",
truffleColors.mint("(enter)") +
" last command entered (" +
Function tabsToSpaces
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
tabsToSpaces: function (inputLine, tabLength = DEFAULT_TAB_WIDTH) {
//note: I'm going to assume for these purposes that everything is
//basically ASCII and I don't have to worry about astral planes or
//grapheme clusters. Sorry. :-/
let line = "";
- 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 formatLinePointer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
formatLinePointer: function (
line,
startCol,
endCol,
padding,
- 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 panicString
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
panicString: function (panicCode, verbose = false) {
const unknownString = "Unknown panic";
const verboseUnknownString = "A panic occurred of unrecognized type.";
if (BN.isBN(panicCode)) {
try {
- 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 formatLinePointer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
line,
startCol,
endCol,
padding,
tabLength = DEFAULT_TAB_WIDTH
Function formatRangeLines
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
source,
range,
uncolorizedSource,
contextBefore = 2,
contextAfter = 0
Function formatStorage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
formatStorage: function (storage) {
//storage here is an object mapping hex words to hex words (no 0x)
//first: sort the keys (slice to clone as sort is in-place)
//note: we can use the default sort here; it will do the righ thing
- 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 formatBreakpointLocation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
formatBreakpointLocation: function (
breakpoint,
here,
currentSourceId,
sourceNames
- 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 formatAffectedInstances
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
formatAffectedInstances: function (instances) {
var hasAllSource = true;
var lines = Object.keys(instances).map(function (address) {
var instance = instances[address];
- 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
const shortCommandReference = {
"o": "step over",
"i": "step into",
"u": "step out",
"n": "step next",
- 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 138.
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
const commandReference = {
"o": "step over",
"i": "step line / step into",
"u": "step out",
"n": "step next",
- 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 138.
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
const panicTable = {
0x01: "Failed assertion",
0x11: "Arithmetic overflow",
0x12: "Division by zero",
0x21: "Enum value out of bounds",
- 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 53.
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
const verbosePanicTable = {
0x01: "An assert() check was not satisfied.",
0x11: "An arithmetic overflow occurred outside an unchecked { ... } block.",
0x12: "A division by zero occurred.",
0x21: "An integer was cast to an enum type that cannot hold it.",
- 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 53.
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