trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Function init has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  public async init(): Promise<void> {
    this.contractCode = Conversion.toHexString(
      await this.getCode(
        this.contractAddress,
        await this.providerAdapter.getBlockNumber() //not "latest" because regularized
Severity: Minor
Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

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 normalizeSourcePath has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

export const normalizeSourcePath = (url = defaultPath) => {
  // Process filepath resolution
  //
  if (url.startsWith(".") || url.startsWith("/") || url.startsWith("~")) {
    debug({ in: url, out: path.normalize(url) });
Severity: Minor
Found in packages/box/box.ts - About 2 hrs to fix

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 constructSlot has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  private async constructSlot(
    variable: number | string,
    ...indices: unknown[]
  ): Promise<{ slot?: Storage.Slot; type?: Format.Types.Type }> {
    //base case: we need to locate the variable and its definition
Severity: Minor
Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

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 iterate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  *iterate({ inputs }) {
    for (const [compilationIndex, { sources, contracts }] of inputs.entries()) {
      for (const [sourceIndex, source] of sources.entries()) {
        yield {
          input: source,
Severity: Minor
Found in packages/db/src/project/loadCompile/sources.ts - About 2 hrs to fix

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

    "obtain:start": [
      function () {
        if (this.quiet) {
          return;
        }
Severity: Major
Found in packages/events/defaultSubscribers/obtain.js and 1 other location - About 2 hrs to fix
packages/events/defaultSubscribers/unbox.js on lines 23..31

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 80.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    "unbox:start": [
      function () {
        if (this.quiet) {
          return;
        }
Severity: Major
Found in packages/events/defaultSubscribers/unbox.js and 1 other location - About 2 hrs to fix
packages/events/defaultSubscribers/obtain.js on lines 9..17

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 80.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    for (const subDir of subDirs) {
      const possiblePath = path.join(
        packagePath,
        subDir,
        `${contractName}.json`
Severity: Major
Found in packages/resolver/lib/sources/globalnpm.ts and 1 other location - About 2 hrs to fix
packages/resolver/lib/sources/npm.ts on lines 66..78

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 80.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    for (const subDir of subDirs) {
      const possiblePath = path.join(
        packagePath,
        subDir,
        `${contractName}.json`
Severity: Major
Found in packages/resolver/lib/sources/npm.ts and 1 other location - About 2 hrs to fix
packages/resolver/lib/sources/globalnpm.ts on lines 38..50

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 80.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            <C.Container prefix="{" suffix="}" empty={false}>
              <mark style={{ backgroundColor: "hsl(60,48%,60%)" }}>0x1234</mark>
              <mark style={{ backgroundColor: "hsl(60,64%,60%)" }}>
                0xbc1f71253612b66b5938e6cc90b161676ff66a905c76d8216a8c187fd42ded88941924d65b325914
              </mark>
Severity: Major
Found in packages/codec-components/src/docs/content.tsx and 1 other location - About 2 hrs to fix
packages/codec-components/src/docs/content.tsx on lines 508..523

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 80.

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

Further Reading

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;
Severity: Major
Found in packages/debug-utils/index.js - About 2 hrs to fix

    Function interpretCallInAggregate has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private async interpretCallInAggregate(
        callResult: Format.Values.StructResult | Format.Values.TupleResult,
        transaction: DecoderTypes.Transaction,
        additionalContexts: Contexts.Contexts = {},
        additionalAllocations?: {
    Severity: Major
    Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

      Function parseParameterListWithRemainder has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function parseParameterListWithRemainder(parameterList: string): {
        parameters: Parameter[];
        remaining: string;
      } {
        if (parameterList === "") {
      Severity: Major
      Found in packages/abi-utils/lib/parse.ts - About 2 hrs to fix

        Function save has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public async save<N extends CollectionName<C>, T>(
            collectionName: N,
            records: (Record<T> | undefined)[],
            options: { overwrite?: boolean } = {}
          ): Promise<(SavedRecord<T> | undefined)[]> {
        Severity: Major
        Found in packages/db/src/meta/pouch/adapters/base.ts - About 2 hrs to fix

          File index.tsx has 260 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { useState, useEffect } from "react";
          import { Input, Button, Header, Grid, createStyles } from "@mantine/core";
          import { useInputState, useCounter, useLocalStorage } from "@mantine/hooks";
          import Controls from "src/components/composed/Debugger/Controls";
          import Sources from "src/components/composed/Debugger/Sources";
          Severity: Minor
          Found in packages/dashboard/src/components/composed/Debugger/index.tsx - About 2 hrs to fix

            File run.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module.exports = async function (options) {
              const debug = require("debug")("core:commands:call");
              const fs = require("fs");
              const util = require("util");
              const { Environment } = require("@truffle/environment");
            Severity: Minor
            Found in packages/core/lib/commands/call/run.js - About 2 hrs to fix

              Function decodeCall has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function* decodeCall(decodeCurrent = false) {
                const isCall = yield select(data.current.isCall);
                const isCreate = yield select(data.current.isCreate);
                if (!isCall && !isCreate && !decodeCurrent) {
                  return null;
              Severity: Major
              Found in packages/debugger/lib/data/sagas/index.js - About 2 hrs to fix

                Function decode has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function* decode(definition, ref, compilationId) {
                  const userDefinedTypes = yield select(data.views.userDefinedTypes);
                  const state = yield select(data.current.state);
                  const mappingKeys = yield select(data.views.mappingKeys);
                  const allocations = yield select(data.info.allocations);
                Severity: Major
                Found in packages/debugger/lib/data/sagas/index.js - About 2 hrs to fix

                  Function parseQuotesAndEscapes has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function parseQuotesAndEscapes(args, escapeCharacters = "\\") {
                    const quoteCharacters = "\"'"; //note we will handle the two quote types differently
                    let argArray = [];
                    let currentArg = "";
                    let currentQuote = undefined;
                  Severity: Major
                  Found in packages/core/lib/command-utils.js - About 2 hrs to fix

                    Function sourcesWithDependencies has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async sourcesWithDependencies({
                        paths,
                        options
                      }: SourcesWithDependenciesArgs) {
                        if (options.compilers.solc.version === "pragma") {
                    Severity: Major
                    Found in packages/compile-solidity/src/index.ts - About 2 hrs to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          try {
                            return {
                              compile: options =>
                                String(execSync(command, { input: options, maxBuffer })),
                              version: () => versionString
                      packages/compile-solidity/src/compilerSupplier/loadingStrategies/Docker.ts on lines 45..56

                      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

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language