trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

export interface DashboardMessageBusClientOptions {
  host?: string;
  port?: number;
  subscribePort?: number;
  publishPort?: number;
Severity: Minor
Found in packages/dashboard-message-bus-client/lib/types.ts and 1 other location - About 50 mins to fix
packages/dashboard-message-bus-client/lib/types.ts on lines 12..19

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

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

          gasprice: yield* Basic.Decode.decodeBasic(
            {
              typeClass: "uint" as const,
              bits: 256
            },
Severity: Minor
Found in packages/codec/lib/special/decode/index.ts and 1 other location - About 50 mins to fix
packages/codec/lib/special/decode/index.ts on lines 111..118

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

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

        block.prevrandao = yield* Basic.Decode.decodeBasic(
          {
            typeClass: "uint" as const,
            bits: 256
          },
Severity: Minor
Found in packages/codec/lib/special/decode/index.ts and 1 other location - About 50 mins to fix
packages/codec/lib/special/decode/index.ts on lines 89..96

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

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

  const preparingSession =
    status === SessionStatus.PreparingForInitialization ||
    status === SessionStatus.Initializing ||
    status === SessionStatus.Fetching ||
    status === SessionStatus.Starting;
Severity: Minor
Found in packages/dashboard/src/components/composed/Debugger/index.tsx and 1 other location - About 50 mins to fix
packages/dashboard/src/components/composed/Debugger/index.tsx on lines 96..100

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

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

Avoid deeply nested control flow statements.
Open

        if (!(yield select(txlog.current.waitingForInternalCallToAbsorb))) {
          const newPointer = yield select(txlog.current.nextActionPointer);
          debug("internal call: %o %o", pointer, newPointer);
          yield put(actions.internalCall(pointer, newPointer, step));
        } else {
Severity: Major
Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                for (let index in generatedSources) {
                  index = Number(index); //it comes out as a string due to in, so let's fix that
                  const source = generatedSources[index];
                  // VSCode extension breaks w/o this check
                  if (source) {
    Severity: Major
    Found in packages/debugger/lib/session/index.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  for (let index in deployedGeneratedSources) {
                    index = Number(index); //it comes out as a string due to in, so let's fix that
                    const source = deployedGeneratedSources[index];
                    // VSCode extension breaks w/o this check
                    if (source) {
      Severity: Major
      Found in packages/debugger/lib/session/index.js - About 45 mins to fix

        Function decodeCall has a Cognitive Complexity of 8 (exceeds 5 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: Minor
        Found in packages/debugger/lib/data/sagas/index.js - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

              if (!internal && astMatchesTxLog) {
                //in this case, we have to do decoding & fn identification
                const newPointer = yield select(txlog.current.internalReturnPointer);
                const outputAllocations = yield select(
                  txlog.current.outputParameterAllocations
        Severity: Major
        Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

              if (instant) {
                const status = yield select(txlog.current.returnStatus);
                debug("instacreate: %o %o", pointer, newPointer);
                yield put(
                  actions.instantCreate(
          Severity: Major
          Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

            Function fetchTransactionInfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function* fetchTransactionInfo(adapter, { txHash }) {
              debug("inspecting transaction");
              var trace;
              try {
                trace = yield apply(adapter, adapter.getTrace, [txHash]);
            Severity: Minor
            Found in packages/debugger/lib/web3/sagas/index.js - About 45 mins 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 continueUntilBreakpoint has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function* continueUntilBreakpoint(action) {
              //if breakpoints was not specified, use the stored list from the state.
              //if it was, override that with the specified list.
              //note that explicitly specifying an empty list will advance to the end.
              let breakpoints =
            Severity: Minor
            Found in packages/debugger/lib/controller/sagas/index.js - About 45 mins 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

            Avoid deeply nested control flow statements.
            Open

                    if (Codec.Ast.Utils.isSimpleConstant(indexConstantDefinition)) {
                      debug("about to decode simple constant");
                      return yield* decode(
                        keyDefinition,
                        {
            Severity: Major
            Found in packages/debugger/lib/data/sagas/index.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                } else if (yield select(txlog.current.isLog)) {
                  const decoding = (yield* data.decodeLog())[0]; //just assume first decoding is correct
                  //(note: because we know the event ID, there should typically only be one decoding)
                  const rawInfo = yield select(txlog.current.rawEventInfo);
                  const newPointer = yield select(txlog.current.nextActionPointer);
              Severity: Major
              Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

                Function yulWalk has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                function* yulWalk(
                  sourceId,
                  sourceIndex,
                  node,
                  pointer,
                Severity: Minor
                Found in packages/debugger/lib/ast/sagas/index.js - About 45 mins 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 processInput has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                const processInput = input => {
                  const words = input.trim().split(/\s+/);
                
                  // empty input
                  if (words.length === 0) return input;
                Severity: Minor
                Found in packages/core/lib/console.js - About 45 mins 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 exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = async options => {
                  const TruffleError = require("@truffle/error");
                  const { Plugins } = require("@truffle/plugins");
                  const { getConfig, constructRecipes } = require("./plugins");
                  const { preserve, ConsoleReporter } = require("@truffle/preserve");
                Severity: Minor
                Found in packages/core/lib/commands/preserve/run.js - About 45 mins 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 convertENSArgsNames has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  convertENSArgsNames: function ({
                    inputArgs,
                    methodABI,
                    web3,
                    registryAddress,
                Severity: Minor
                Found in packages/contract/lib/utils/ens.js - About 45 mins 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 exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = async function (options) {
                  const Config = require("@truffle/config");
                  const WorkflowCompile = require("@truffle/workflow-compile").default;
                  const ConfigurationError = require("../../errors/configurationerror");
                  const exec = require("@truffle/require").exec;
                Severity: Minor
                Found in packages/core/lib/commands/exec/run.js - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                      if (!whitespace) {
                        //if we're already on whitespace, we don't need
                        //to do anything, this is just more whitespace.
                        //if however we're transitioning to whitespace, that means we need
                        //to split arguments here.
                Severity: Major
                Found in packages/core/lib/command-utils.js - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language