trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Function parseImports has 41 lines of code (exceeds 25 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

    Function forContract has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function forContract(contract: CompiledContract): any {
      const {
        contractName,
        sourcePath,
        source,
    Severity: Minor
    Found in packages/compile-common/src/shims/NewToLegacy.ts - About 1 hr to fix

      Function inspectTransaction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function* inspectTransaction(txHash) {
        debug("putting");
        yield put(actions.inspect(txHash));
      
        debug("waiting");
      Severity: Minor
      Found in packages/debugger/lib/web3/sagas/index.js - About 1 hr to fix

        Function processTrace has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function* processTrace(steps) {
          yield put(actions.saveSteps(steps));
        
          let callAddresses = new Set();
          let selfDestructAddresses = new Set();
        Severity: Minor
        Found in packages/debugger/lib/trace/sagas/index.js - About 1 hr to fix

          Function send has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            send: function (fn, methodABI, address) {
              const constructor = this;
              const web3 = constructor.web3;
          
              return function () {
          Severity: Minor
          Found in packages/contract/lib/execute.js - About 1 hr to fix

            Function event has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              event: function (fn) {
                const constructor = this;
                const decode = utils.decodeLogs;
                let currentLogID = null;
            
            
            Severity: Minor
            Found in packages/contract/lib/execute.js - About 1 hr to fix

              Function RPCs has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function RPCs(): JSX.Element {
                const { state } = useDash()!;
                const { classes } = useStyles();
              
                const content = Array.from(
              Severity: Minor
              Found in packages/dashboard/src/components/composed/RPCs/index.tsx - About 1 hr to fix

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

                    "fetchSolcList:start": [
                      function ({ attemptNumber }) {
                        if (this.quiet) {
                          return;
                        }
                Severity: Major
                Found in packages/events/defaultSubscribers/obtain.js and 1 other location - About 1 hr to fix
                packages/events/defaultSubscribers/obtain.js on lines 41..54

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

                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

                    "downloadCompiler:start": [
                      function ({ attemptNumber }) {
                        if (this.quiet) {
                          return;
                        }
                Severity: Major
                Found in packages/events/defaultSubscribers/obtain.js and 1 other location - About 1 hr to fix
                packages/events/defaultSubscribers/obtain.js on lines 71..81

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export class InvalidAddressError extends Error {
                  public address: string;
                  constructor(address: string) {
                    super(`Invalid address ${address}`);
                    this.address = address;
                Severity: Major
                Found in packages/encoder/lib/errors.ts and 1 other location - About 1 hr to fix
                packages/decoder/lib/errors.ts on lines 86..93

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

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                export class InvalidAddressError extends Error {
                  public address: string;
                  constructor(address: string) {
                    super(`Invalid address ${address}`);
                    this.address = address;
                Severity: Major
                Found in packages/decoder/lib/errors.ts and 1 other location - About 1 hr to fix
                packages/encoder/lib/errors.ts on lines 52..59

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

                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 async function forArtifact(
                  artifact: Artifact,
                  settings: DecoderSettings
                ): Promise<ContractDecoder> {
                  if (!settings.projectInfo) {
                Severity: Major
                Found in packages/decoder/lib/index.ts and 1 other location - About 1 hr to fix
                packages/encoder/lib/index.ts on lines 233..245

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

                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 async function forArtifact(
                  artifact: Artifact,
                  settings: EncoderSettings = {}
                ): Promise<ContractEncoder> {
                  if (!settings.projectInfo) {
                Severity: Major
                Found in packages/encoder/lib/index.ts and 1 other location - About 1 hr to fix
                packages/decoder/lib/index.ts on lines 217..229

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

                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 data = <Uint8Array>(
                      Codec.AbiData.Encode.encodeTupleAbiWithSelector(
                        resolution.arguments,
                        Codec.Conversion.toBytes(resolution.method.selector),
                        this.allocations.abi
                Severity: Major
                Found in packages/encoder/lib/encoders.ts and 1 other location - About 1 hr to fix
                packages/encoder/lib/encoders.ts on lines 303..309

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

                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 data = <Uint8Array>(
                      Codec.AbiData.Encode.encodeTupleAbiWithSelector(
                        resolution.arguments,
                        Codec.Conversion.toBytes(resolution.method.selector),
                        this.allocations.abi
                Severity: Major
                Found in packages/encoder/lib/encoders.ts and 1 other location - About 1 hr to fix
                packages/encoder/lib/encoders.ts on lines 333..339

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

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

                  _decode: function (rawData, web3) {
                    const errorStringHash = "0x08c379a0";
                    const panicCodeHash = "0x4e487b71";
                    const selectorLength = 2 + 2 * 4; //0x then 4 bytes (0x then 8 hex digits)
                    const wordLength = 2 * 32; //32 bytes (64 hex digits)
                Severity: Minor
                Found in packages/contract/lib/reason.js - 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 compile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  compile: async function (options, callback) {
                    const callbackPassed = typeof callback === "function";
                    try {
                      const config = prepareConfig(options);
                
                
                Severity: Minor
                Found in packages/workflow-compile/legacy/index.js - 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 decodeTransactionBySelector has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  private async decodeTransactionBySelector(
                    transaction: DecoderTypes.Transaction,
                    data: Uint8Array, //this is redundant but included for convenience
                    additionalContexts: Contexts.Contexts,
                    context: Contexts.Context | null
                Severity: Minor
                Found in packages/decoder/lib/decoders.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 decodeTransactionWithAdditionalContexts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  public async decodeTransactionWithAdditionalContexts(
                    transaction: DecoderTypes.Transaction,
                    additionalContexts: Contexts.Contexts = {},
                    additionalAllocations?: {
                      [
                Severity: Minor
                Found in packages/decoder/lib/decoders.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 preserve has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                export async function* preserve(
                  options: PreserveOptions
                ): AsyncIterable<Event> {
                  const { request, recipes } = options;
                  const { recipe } = request;
                Severity: Minor
                Found in packages/preserve/lib/preserve.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

                Severity
                Category
                Status
                Source
                Language