trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Function parseImports has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  parseImports(body, solc) {
    // WARNING: Kind of a hack (an expedient one).

    // So we don't have to maintain a separate parser, we'll get all the imports
    // in a file by sending the file to solc and evaluating the error messages
Severity: Minor
Found in packages/compile-solidity/src/parser.ts - About 1 hr 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 readAndParseArtifactFiles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function readAndParseArtifactFiles(
  paths: string[],
  contracts_build_directory: string
): SourceFilesArtifacts {
  const sourceFilesArtifacts: SourceFilesArtifacts = {};
Severity: Minor
Found in packages/profiler/src/updated.ts - About 1 hr 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 method has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          var method = function (constant, web3Method) {
            var fn;

            constant
              ? (fn = execute.call.call(
Severity: Minor
Found in packages/contract/lib/contract/index.js - About 1 hr to fix

    Function validate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      validate: function (contractObj) {
        var ajv = new Ajv({ verbose: true });
        ajv.addSchema(abiSchema);
        ajv.addSchema(networkObjectSchema);
        ajv.addSchema(contractObjectSchema);
    Severity: Minor
    Found in packages/contract-schema/index.js - About 1 hr to fix

      Function iterate has 39 lines of code (exceeds 25 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 1 hr to fix

        Function Middle has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Middle(): JSX.Element {
          const {
            state: { providerMessages }
          } = useDash()!;
          const numRequests = providerMessages.size;
        Severity: Minor
        Found in packages/dashboard/src/components/composed/Sidebar/Middle/index.tsx - About 1 hr to fix

          Function collectSources has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function collectSources(
            originalSources: Sources,
            originalTargets: string[] = [],
            baseDirectory: string = "",
            replacement: string = "/"
          Severity: Minor
          Found in packages/compile-common/src/sources.ts - About 1 hr to fix

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

            export const { UnknownCreationDecoding } = createCodecComponent(
              "UnknownCreationDecoding",
              ({ bytecode }: Codec.UnknownCreationDecoding) => (
                <Code type="bytes" title="contract (unknown) creation">
                  {bytecode}
            packages/codec-components/src/react/components/codec/raw-return-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-bytecode-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-call-decoding.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 66.

            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

              public async forInstance(
                artifact: Artifact,
                address?: string
              ): Promise<ContractInstanceDecoder> {
                let contractDecoder = await this.forArtifact(artifact);
            Severity: Major
            Found in packages/decoder/lib/decoders.ts and 1 other location - About 1 hr to fix
            packages/encoder/lib/encoders.ts on lines 577..583

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

            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

                      <Button
                        size="md"
                        onClick={onRejectButtonClick}
                        onMouseEnter={onRejectButtonEnter}
                        onMouseLeave={onRejectButtonLeave}
            packages/dashboard/src/components/composed/RPCs/RPC/Overview.tsx on lines 220..228

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

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

            export const { UnknownBytecodeDecoding } = createCodecComponent(
              "UnknownBytecodeDecoding",
              ({ bytecode }: Codec.UnknownBytecodeDecoding) => (
                <Code type="bytes" title="contract (unknown) bytecode">
                  {bytecode}
            packages/codec-components/src/react/components/codec/raw-return-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-call-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-creation-decoding.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 66.

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

            export const { UnknownCallDecoding } = createCodecComponent(
              "UnknownCallDecoding",
              ({ data }: Codec.UnknownCallDecoding) => (
                <Code type="bytes" title="data sent to contract (unknown)">
                  {data}
            packages/codec-components/src/react/components/codec/raw-return-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-bytecode-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-creation-decoding.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 66.

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

            export const { RawReturnDecoding } = createCodecComponent(
              "RawReturnDecoding",
              ({ data }: Codec.RawReturnDecoding) => (
                <Code type="bytes" title="raw return data">
                  {data}
            packages/codec-components/src/react/components/codec/unknown-bytecode-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-call-decoding.tsx on lines 6..13
            packages/codec-components/src/react/components/codec/unknown-creation-decoding.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 66.

            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 [isTypeValueContract, , , typeValueContractGuards] =
              valueAndResultTypeGuardHelper<Format.Values.TypeValueContract, never, never>(
                data =>
                  data.type.typeClass === "type" && data.type.type.typeClass === "contract"
              );
            packages/codec-components/src/utils/type-guards/value-and-result/type-value-enum.ts on lines 4..8

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

            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

              public async forInstance(
                artifact: Artifact,
                address?: string
              ): Promise<ContractInstanceEncoder> {
                const contractEncoder = await this.forArtifact(artifact);
            Severity: Major
            Found in packages/encoder/lib/encoders.ts and 1 other location - About 1 hr to fix
            packages/decoder/lib/decoders.ts on lines 833..839

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

            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 [isTypeValueEnum, , , typeValueEnumGuards] =
              valueAndResultTypeGuardHelper<Format.Values.TypeValueEnum, never, never>(
                data =>
                  data.type.typeClass === "type" && data.type.type.typeClass === "enum"
              );
            packages/codec-components/src/utils/type-guards/value-and-result/type-value-contract.ts on lines 4..8

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

            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

                      <Button
                        size="md"
                        onClick={onDebugButtonClick}
                        onMouseEnter={onDebugButtonEnter}
                        onMouseLeave={onDebugButtonLeave}
            packages/dashboard/src/components/composed/RPCs/RPC/Overview.tsx on lines 198..206

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

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

                  (node, invocation, index, next, nextInvocation, isContextChange) => {
                    //ensure: current instruction is not a context change (because if it is
                    //we cannot rely on the data.next selectors, but also if it is we know
                    //we're not about to call a modifier or base constructor!)
                    //we also want to return false if we can't find things for whatever
            Severity: Minor
            Found in packages/debugger/lib/data/selectors/index.js - About 1 hr to fix

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

              module.exports = async function (options) {
                const OS = require("os");
                const deprecationMessage = colors.yellow(
                  `> The watch command is planned ` +
                    `for deprecation in version 6 of Truffle.${OS.EOL}` +
              Severity: Minor
              Found in packages/core/lib/commands/watch/run.js - About 1 hr to fix

                Function listVersions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const listVersions = async function (options) {
                  const { CompilerSupplier } = require("@truffle/compile-solidity");
                  const { asyncTake } = require("iter-tools");
                
                  const supplier = new CompilerSupplier({
                Severity: Minor
                Found in packages/core/lib/commands/compile/run.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language