trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Function markTextHighlighted has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function markTextHighlighted(source: Source, sourceRange: SourceRange) {
  const fullyHighlightedLines = new Set<number>();
  const editedLines = source.contents.split("\n").map((line, index) => {
    if (line.length === 0) {
      return line;

    Function resolve has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      async resolve(
        importModule: string,
        importedFrom: string,
        options: { compiler?: { name: string } } = {}
      ) {
    Severity: Minor
    Found in packages/resolver/lib/sources/vyper.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

    File sourcify.ts has 288 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import debugModule from "debug";
    const debug = debugModule("source-fetcher:sourcify");
    
    import type { Fetcher, FetcherConstructor } from "./types";
    import type * as Types from "./types";
    Severity: Minor
    Found in packages/source-fetcher/lib/sourcify.ts - About 2 hrs to fix

      Function Variables has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Variables(): JSX.Element | null {
        const { classes } = useStyles();
        const {
          state: {
            debugger: { session }
      Severity: Major
      Found in packages/dashboard/src/components/composed/Debugger/Variables.tsx - About 2 hrs to fix

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

        export const { EnumNotFoundDecodingError } = createCodecComponent(
          "EnumNotFoundDecodingError",
          ({ kind, type, rawAsBN }: Format.Errors.EnumNotFoundDecodingError) => (
            <CodecError kind={kind}>
              {type.typeName}.? ({rawAsBN.toString()})
        packages/codec-components/src/react/components/codec/format.errors.enum-out-of-range-error.tsx on lines 6..13

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

        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

        export const { EnumOutOfRangeError } = createCodecComponent(
          "EnumOutOfRangeError",
          ({ kind, type, rawAsBN }: Format.Errors.EnumOutOfRangeError) => (
            <CodecError kind={kind}>
              {type.typeName}.? ({rawAsBN.toString()})
        packages/codec-components/src/react/components/codec/format.errors.enum-not-found-decoding-error.tsx on lines 6..13

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

        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 tryFetchAndCompileAddress has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function tryFetchAndCompileAddress(
          address: string,
          fetchers: Fetcher[],
          recognizer: Recognizer,
          fetchAndCompileOptions: FetchAndCompileOptions
        Severity: Major
        Found in packages/fetch-and-compile/lib/fetch.ts - About 2 hrs to fix

          Function stacktraceSaga has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function* stacktraceSaga() {
            const currentLocation = yield select(stacktrace.current.strippedLocation);
            const lastLocation = yield select(stacktrace.current.lastPosition);
            const returnCounter = yield select(stacktrace.current.returnCounter);
            let positionUpdated = false;
          Severity: Major
          Found in packages/debugger/lib/stacktrace/sagas/index.js - About 2 hrs to fix

            Function exports has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

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

                testProp(
                  "abiSignature undoes parseErrorSignature",
                  [Arbitrary.ErrorEntry()],
                  entry => {
                    const correctSignature = Signature.abiSignature(entry as ErrorEntry); //sorry
              Severity: Major
              Found in packages/abi-utils/lib/parse.test.ts and 2 other locations - About 2 hrs to fix
              packages/abi-utils/lib/parse.test.ts on lines 11..20
              packages/abi-utils/lib/parse.test.ts on lines 33..42

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

              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

                  {
                    name: "To",
                    node: (
                      <Text>
                        <Text bold>{transaction.to}</Text>
              Severity: Major
              Found in packages/db-kit/src/cli/components/codec/Function.tsx and 1 other location - About 2 hrs to fix
              packages/db-kit/src/cli/components/codec/Constructor.tsx on lines 22..32

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

              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 3 locations. Consider refactoring.
              Open

                testProp(
                  "abiSignature undoes parseFunctionSignature",
                  [Arbitrary.FunctionEntry()],
                  entry => {
                    const correctSignature = Signature.abiSignature(entry as FunctionEntry); //sorry
              Severity: Major
              Found in packages/abi-utils/lib/parse.test.ts and 2 other locations - About 2 hrs to fix
              packages/abi-utils/lib/parse.test.ts on lines 22..31
              packages/abi-utils/lib/parse.test.ts on lines 33..42

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

              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 3 locations. Consider refactoring.
              Open

                testProp(
                  "abiSignature undoes parseEventSignature",
                  [Arbitrary.EventEntry()],
                  entry => {
                    const correctSignature = Signature.abiSignature(entry as EventEntry); //sorry
              Severity: Major
              Found in packages/abi-utils/lib/parse.test.ts and 2 other locations - About 2 hrs to fix
              packages/abi-utils/lib/parse.test.ts on lines 11..20
              packages/abi-utils/lib/parse.test.ts on lines 22..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 91.

              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

                  {
                    name: "Created",
                    node: (
                      <Text>
                        <Text bold>{receipt.contractAddress}</Text>
              Severity: Major
              Found in packages/db-kit/src/cli/components/codec/Constructor.tsx and 1 other location - About 2 hrs to fix
              packages/db-kit/src/cli/components/codec/Function.tsx on lines 22..32

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

              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

              File schema.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { logger } from "@truffle/db/logger";
              const debug = logger("db:meta:graph:schema");
              
              import gql from "graphql-tag";
              import type * as graphql from "graphql";
              Severity: Minor
              Found in packages/db/src/meta/graph/schema.ts - About 2 hrs to fix

                Function continueUntilBreakpoint has 69 lines of code (exceeds 25 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: Major
                Found in packages/debugger/lib/controller/sagas/index.js - About 2 hrs to fix

                  Function interpretCallInAggregate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private async interpretCallInAggregate(
                      callResult: Format.Values.StructResult | Format.Values.TupleResult,
                      transaction: DecoderTypes.Transaction,
                      additionalContexts: Contexts.Contexts = {},
                      additionalAllocations?: {
                  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 run has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export async function run(
                    rawSources: { [name: string]: string },
                    options: Config,
                    internalOptions: InternalOptions = {}
                  ): Promise<Compilation | null> {
                  Severity: Major
                  Found in packages/compile-solidity/src/run.ts - About 2 hrs to fix

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

                          createBytecode: {
                            resolve: async ({ createBytecode }, _, { workspace }) => {
                              debug("Resolving Contract.createBytecode...");
                    
                              if (!createBytecode) {
                    Severity: Major
                    Found in packages/db/src/resources/contracts.ts and 2 other locations - About 2 hrs to fix
                    packages/db/src/resources/contracts.ts on lines 179..194
                    packages/db/src/resources/nameRecords.ts on lines 49..64

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

                    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 3 locations. Consider refactoring.
                    Open

                          previous: {
                            resolve: async ({ previous }, _, { workspace }) => {
                              debug("Resolving NameRecord.previous...");
                    
                              if (!previous) {
                    Severity: Major
                    Found in packages/db/src/resources/nameRecords.ts and 2 other locations - About 2 hrs to fix
                    packages/db/src/resources/contracts.ts on lines 163..178
                    packages/db/src/resources/contracts.ts on lines 179..194

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

                    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