Showing 1,401 of 1,401 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
export interface ContractValue {
type: Types.ContractType;
kind: "value";
value: ContractValueInfo;
interpretations: {
- 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 61.
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
Function getExistingStorage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getExistingStorage(address, slot, blockHash, txIndex) {
debug("slot: %O", slot);
const provider = this.web3.currentProvider;
const hashedSlot = Web3.utils.soliditySha3({
type: "bytes",
Function deployed
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
deployed: async function(options) {
let files;
try {
// Only read JSON files in directory
files = fs
Function clone
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
clone(json) {
json = json || {};
const temp = function TruffleContract() {
this.constructor = temp;
Function fork
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
fork: async function (config, ganacheOptions) {
expect.options(config, ["from", "provider", "networks", "network"]);
const interfaceAdapter = createInterfaceAdapter({
provider: config.provider,
Function typeDefs
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
get typeDefs() {
const log = debug.extend(`${this.resource}:typeDefs`);
log("Generating...");
const { typeDefs } = this.definition;
Function collectPairwiseGenealogies
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function collectPairwiseGenealogies<
Network extends Pick<Resource<"networks">, "id" | "historicBlock">
>(options: { networks: Network[] }): Input<"networkGenealogies">[] {
const { networks } = options;
Function configure
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const configure = <C extends Config>(options: Options<C>) => {
const processCollection = configureForCollection(options);
return function* <I extends Input<C>, O extends Output<C>>(options: {
project: IdObject<"projects">;
Function findYulScopePointer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function findYulScopePointer(node, pointer, base, basePointer) {
//walk upward until we find a YulBlock or YulFunctionDefinition,
//with a special case for YulForLoop
debug("pointer: %s", pointer);
debug("basePointer: %s", basePointer);
- 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 callstack
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function callstack(state = [], action) {
let newFrame;
switch (action.type) {
case actions.JUMP_IN:
const {
- 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 instantCreate
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
pointer,
newPointer, //does not actually affect the current pointer!
step,
address,
context,
Function state
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
(allAllocations, compilationId, { isConstructor }) => {
debug("compilationId: %s", compilationId);
debug("allAllocations: %o", allAllocations);
const allocations = compilationId
? allAllocations[compilationId]
- 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 callKind
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function callKind(context, calldata, instant) {
if (context) {
if (context.contractKind === "library") {
return instant ? "message" : "library";
//for an instant return, just get it out of the way and set it to
- 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 generateReport
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function generateReport(rawStack, location, status, message) {
//step 1: process combined frames
let callstack = [];
//we're doing a C-style loop here!
//because we want to skip some items <grin>
- 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 _extract
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_extract: function (res, web3, _interfaceAdapter) {
//I'm not sure why interfaceAdapter is here if it's not used,
//so I just put an underscore in front of its name for now...
if (!res || (!res.error && !res.result)) return;
- 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 getHumanReadableSourceMap
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
getHumanReadableSourceMap: function (sourceMap) {
const instructions = sourceMap.split(";");
let processedInstruction = {
start: 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 setOrClearBreakpointObject
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async setOrClearBreakpointObject(breakpoint, setOrClear) {
const existingBreakpoints = this.session.view(controller.breakpoints);
//OK, we've constructed the breakpoint! But if we're adding, we'll
//want to adjust to make sure we don't set it on an empty line or
//anything like that
- 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 abiParameterToType
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function abiParameterToType(abi: Parameter): Format.Types.Type {
let typeName = abi.type;
let typeHint = abi.internalType;
//first: is it an array?
let arrayMatch = typeName.match(/(.*)\[(\d*)\]$/);
- 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 needsMigrating
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
needsMigrating: function (options: Config) {
return new Promise((resolve, reject) => {
if (options.reset === true) return resolve(true);
return this.lastCompletedMigration(options)
- 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 reportSources
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const reportSources = ({ paths, options }) => {
if (options.quiet !== true && options.events) {
if (!Array.isArray(paths)) {
paths = Object.keys(paths);
}
- 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"