trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

export const { GenericError } = createCodecComponent(
  "GenericError",
  (data: Format.Errors.GenericError) =>
    isUserDefinedTypeNotFoundError(data) ? (
      <UserDefinedTypeNotFoundError data={data} />
packages/codec-components/src/react/components/codec/format.errors.enum-error.tsx on lines 9..19
packages/codec-components/src/react/components/codec/format.errors.internal-use-error.tsx on lines 12..22
packages/codec-components/src/react/components/codec/format.values.function-external-value-info.tsx on lines 12..22
packages/codec-components/src/react/components/codec/format.values.function-internal-value-info.tsx on lines 12..22

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

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

  } else if (yield select(evm.current.step.isStore)) {
    let storageAddress = (yield select(evm.current.call)).storageAddress;
    let slot = yield select(evm.current.step.storageAffected);
    let storedValue = yield select(evm.current.step.valueStored);
    yield put(actions.store(storageAddress, slot, storedValue));
Severity: Major
Found in packages/debugger/lib/evm/sagas/index.js and 1 other location - About 3 hrs to fix
packages/debugger/lib/evm/sagas/index.js on lines 272..277

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

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

export const { FunctionExternalValueInfo } = createCodecComponent(
  "FunctionExternalValueInfo",
  (data: Format.Values.FunctionExternalValueInfo) =>
    isFunctionExternalValueInfoKnown(data) ? (
      <FunctionExternalValueInfoKnown data={data} />
packages/codec-components/src/react/components/codec/format.errors.enum-error.tsx on lines 9..19
packages/codec-components/src/react/components/codec/format.errors.generic-error.tsx on lines 12..22
packages/codec-components/src/react/components/codec/format.errors.internal-use-error.tsx on lines 12..22
packages/codec-components/src/react/components/codec/format.values.function-internal-value-info.tsx on lines 12..22

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

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

const parse = function (args) {
  if (args.length === 0) {
    return null;
  }

Severity: Major
Found in packages/core/lib/commands/config/run.js - About 3 hrs to fix

    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;
    Severity: Minor
    Found in packages/debug-utils/index.js - About 3 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 Debugger has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    function Debugger(): JSX.Element {
      const { classes } = useStyles();
      const [inputValue, setInputValue] = useInputState("");
      const [sessionUpdated, { increment: sessionTick }] = useCounter();
      const {
    Severity: Minor
    Found in packages/dashboard/src/components/composed/Debugger/index.tsx - About 3 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 markTextHighlighted has a Cognitive Complexity of 22 (exceeds 5 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;

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

    export const reducer = (state: State, action: Action): State => {
      const { type, data } = action;
      switch (type) {
        case "set-decoder":
          return { ...state, ...data };
    Severity: Minor
    Found in packages/dashboard/src/contexts/DashContext/state.ts - About 3 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 3 locations. Consider refactoring.
    Open

    export const { MalformedInternalFunctionError } = createCodecComponent(
      "MalformedInternalFunctionError",
      ({
        kind,
        context,
    packages/codec-components/src/react/components/codec/format.errors.deployed-function-in-constructor-error.tsx on lines 7..19
    packages/codec-components/src/react/components/codec/format.errors.no-such-internal-function-error.tsx on lines 7..20

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

    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

    export const { NoSuchInternalFunctionError } = createCodecComponent(
      "NoSuchInternalFunctionError",
      ({
        kind,
        context,
    packages/codec-components/src/react/components/codec/format.errors.deployed-function-in-constructor-error.tsx on lines 7..19
    packages/codec-components/src/react/components/codec/format.errors.malformed-internal-function-error.tsx on lines 7..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 96.

    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

    export const { DeployedFunctionInConstructorError } = createCodecComponent(
      "DeployedFunctionInConstructorError",
      ({
        kind,
        context,
    packages/codec-components/src/react/components/codec/format.errors.malformed-internal-function-error.tsx on lines 7..19
    packages/codec-components/src/react/components/codec/format.errors.no-such-internal-function-error.tsx on lines 7..20

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

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

      display: async function(config) {
        const networks = await this.deployed(config);
        const { networkNames, starNetworks } = Object.keys(networks)
          .sort()
          .reduce(
    Severity: Major
    Found in packages/core/lib/networks.js - About 3 hrs to fix

      Function interpret has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async interpret(input, context, filename, callback) {
          const processedInput = processInput(input);
          if (validTruffleConsoleCommands.includes(processedInput.split(/\s+/)[0])) {
            try {
              parseQuotesAndEscapes(processedInput); //we're just doing this to see
      Severity: Major
      Found in packages/core/lib/console.js - About 3 hrs to fix

        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) {
        Severity: Minor
        Found in packages/debug-utils/index.js - About 3 hrs to fix

          Function normalizeSourcePath has 75 lines of code (exceeds 25 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: Major
          Found in packages/box/box.ts - About 3 hrs to fix

            Function resolveContractInstances has 75 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function resolveContractInstances(
              project: IdObject<"projects">,
              inputs: {
                contract?: DataModel.ResourceNameInput;
                address?: string;
            Severity: Major
            Found in packages/db/src/resources/projects/resolveContractInstances.ts - About 3 hrs to fix

              Function addCompilations has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public async addCompilations(
                  compilations: Compilations.Compilation[]
                ): Promise<void> {
                  //first: make sure we're not adding a compilation with an existing ID
                  const existingIds = new Set(
              Severity: Major
              Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

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

                    this.collections = Object.keys(options.definitions)
                      .map((resource: CollectionName<C>) => ({
                        [resource]: this.createDatabase(resource)
                      }))
                      .reduce((a, b) => ({ ...a, ...b }), {}) as CollectionDatabases<C>;
                Severity: Major
                Found in packages/db/src/meta/pouch/adapters/base.ts and 1 other location - About 2 hrs to fix
                packages/db/src/meta/graph/schema.ts on lines 34..38

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

                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

                    this.collections = Object.keys(options.definitions)
                      .map((resource: CollectionName<C>) => ({
                        [resource]: this.createSchema(resource)
                      }))
                      .reduce((a, b) => ({ ...a, ...b }), {}) as CollectionSchemas<C>;
                Severity: Major
                Found in packages/db/src/meta/graph/schema.ts and 1 other location - About 2 hrs to fix
                packages/db/src/meta/pouch/adapters/base.ts on lines 45..49

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

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

                function mappedPaths(state = DEFAULT_PATHS, action) {
                  switch (action.type) {
                    case actions.MAP_PATH_AND_ASSIGN:
                      let { address, slot, typeIdentifier, parentType } = action;
                      //how this case works: first, we find the spot in our table (based on
                Severity: Major
                Found in packages/debugger/lib/data/reducers.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language