trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

export async function forDeployedArtifact(
  artifact: Artifact,
  settings: DecoderSettings
): Promise<ContractInstanceDecoder> {
  let contractDecoder = await forArtifact(artifact, settings);
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 283..290

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

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 forDeployedArtifact(
  artifact: Artifact,
  settings: EncoderSettings
): Promise<ContractInstanceEncoder> {
  let contractEncoder = await forArtifact(artifact, settings);
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 265..272

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

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 { UnsupportedConstantError } = createCodecComponent(
  "UnsupportedConstantError",
  ({ kind, definition }: Format.Errors.UnsupportedConstantError) => (
    <CodecError kind={kind}>{definition.name}</CodecError>
  )
packages/codec-components/src/react/components/codec/format.errors.user-defined-type-not-found-error.tsx on lines 6..11

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

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

export function* decodeLog() {
  const userDefinedTypes = yield select(data.views.userDefinedTypes);
  const state = yield select(data.current.state); //note: this includes the data to be decoded!
  const allocations = yield select(data.info.allocations);
  const contexts = yield select(data.views.contexts);
Severity: Minor
Found in packages/debugger/lib/data/sagas/index.js - About 1 hr to fix

    Function fromBuildInfo has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      export const fromBuildInfo = (
        buildInfo: Hardhat.BuildInfo
      ): CompiledContract[] => {
        const contracts = [];
        for (const [sourcePath, sourceContracts] of Object.entries(
    Severity: Minor
    Found in packages/from-hardhat/src/compilation.ts - About 1 hr to fix

      Function Layout has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Layout(): JSX.Element {
        const {
          state: { notice, analyticsConfig },
          operations: { updateAnalyticsConfig }
        } = useDash()!;
      Severity: Minor
      Found in packages/dashboard/src/components/composed/Layout.tsx - About 1 hr to fix

        Function processDeploymentError has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          async processDeploymentError(data) {
            const error = data.estimateError || data.error;
        
            data.reason = data.error ? data.error.reason : null;
        
        
        Severity: Minor
        Found in packages/events/defaultSubscribers/migrate/Reporter.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 exports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = fn => {
          // Add our static methods
          // Add something here about excluding send, privately defined methods
          Object.keys(fn._constructorMethods).forEach(function (key) {
            fn[key] = fn._constructorMethods[key].bind(fn);
        Severity: Minor
        Found in packages/contract/lib/contract/bootstrap.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 start has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          start: async function (context, web3Error) {
            const constructor = this;
            let currentBlock = override.defaultMaxBlocks;
        
            // Reject after attempting to get reason string if we shouldn't be waiting.
        Severity: Minor
        Found in packages/contract/lib/override.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 printVariables has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          async printVariables(sectionOuts = this.sectionPrintouts) {
            const values = await this.session.variables();
            const sections = this.session.view(data.current.identifiers.sections);
        
            const sectionNames = {
        Severity: Minor
        Found in packages/core/lib/debug/printer.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 printInstruction has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          printInstruction(locations = this.locationPrintouts) {
            const instruction = this.session.view(sourcemapping.current.instruction);
            const instructions = this.session.view(sourcemapping.current.instructions);
            const step = this.session.view(trace.step);
            const traceIndex = this.session.view(trace.index);
        Severity: Minor
        Found in packages/core/lib/debug/printer.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 scopes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function scopes(state = DEFAULT_SCOPES, action) {
          switch (action.type) {
            case actions.SCOPE: {
              const { sourceId, id, sourceIndex, parentId, pointer } = action;
              const astRef = id !== undefined ? id : makePath(sourceIndex, pointer);
        Severity: Minor
        Found in packages/debugger/lib/data/reducers.js - About 1 hr to fix

          Function flattedEvents has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              flattedEvents: createLeaf(["./transactionLog"], log => {
                const returnStatus = node => {
                  switch (node.returnKind) {
                    case "revert":
                      return false;
          Severity: Minor
          Found in packages/debugger/lib/txlog/selectors/index.js - About 1 hr to fix

            Function rejectHijacker has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function rejectHijacker(e) {
                debug("hijacking!");
                debug("hash: %s", this.txHash);
                let getSolidityStackTrace;
                if (bugger && this.txHash) {
            Severity: Minor
            Found in packages/contract/lib/promievent.js - About 1 hr to fix

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

              module.exports = async function (options) {
                const Config = require("@truffle/config");
                const OS = require("os");
              
                const log = options.logger
              Severity: Minor
              Found in packages/core/lib/commands/config/run.js - About 1 hr to fix

                Function printState has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  printState(
                    contextBefore = 2,
                    contextAfter = 0,
                    location = this.session.view(controller.current.location)
                  ) {
                Severity: Minor
                Found in packages/core/lib/debug/printer.js - About 1 hr to fix

                  Function process has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function* process<
                    Network extends Pick<Resource<"networks">, "id" | keyof Input<"networks">>
                  >(options: { network: IdObject<"networks"> }): Process<Network | undefined> {
                    const {
                      network: { id }
                  Severity: Minor
                  Found in packages/db/src/network/fetch/knownLatest.ts - About 1 hr to fix

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

                    module.exports = {
                      moduleFileExtensions: ["ts", "js", "json", "node"],
                      testEnvironment: "node",
                      transform: {
                        "^.+\\.ts$": "ts-jest"
                    Severity: Major
                    Found in packages/preserve/jest.config.js and 1 other location - About 1 hr to fix
                    packages/dashboard/jest.config.js on lines 1..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 72.

                    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

                    module.exports = {
                      moduleFileExtensions: ["ts", "js", "json", "node"],
                      testEnvironment: "node",
                      transform: {
                        "^.+\\.ts$": "ts-jest"
                    Severity: Major
                    Found in packages/dashboard/jest.config.js and 1 other location - About 1 hr to fix
                    packages/preserve/jest.config.js on lines 1..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 72.

                    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

                          nameRecord: {
                            resolve: async ({ nameRecord: { id } }, _, { workspace }) => {
                              debug("Resolving ProjectName.nameRecord...");
                    
                              const result = await workspace.get("nameRecords", id);
                    Severity: Major
                    Found in packages/db/src/resources/projectNames.ts and 4 other locations - About 1 hr to fix
                    packages/db/src/resources/compilations.ts on lines 154..163
                    packages/db/src/resources/contractInstances.ts on lines 88..97
                    packages/db/src/resources/contractInstances.ts on lines 98..106
                    packages/db/src/resources/projectNames.ts on lines 55..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 72.

                    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