trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

      contract: {
        resolve: async ({ contract: { id } }, _, { workspace }) => {
          debug("Resolving ContractInstance.contract...");
          const result = await workspace.get("contracts", id);

Severity: Major
Found in packages/db/src/resources/contractInstances.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/projectNames.ts on lines 55..64
packages/db/src/resources/projectNames.ts on lines 65..74

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

      source: {
        resolve: async ({ source: { id } }, _, { workspace }) => {
          debug("Resolving ProcessedSource.source...");

          const result = await workspace.get("sources", id);
Severity: Major
Found in packages/db/src/resources/compilations.ts and 4 other locations - About 1 hr to fix
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
packages/db/src/resources/projectNames.ts on lines 65..74

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

      network: {
        resolve: async ({ network: { id } }, _, { workspace }) => {
          debug("Resolving ContractInstance.network...");

          const result = await workspace.get("networks", id);
Severity: Major
Found in packages/db/src/resources/contractInstances.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 98..106
packages/db/src/resources/projectNames.ts on lines 55..64
packages/db/src/resources/projectNames.ts on lines 65..74

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

      project: {
        resolve: async ({ project: { id } }, _, { workspace }) => {
          debug("Resolving ProjectName.project...");

          const result = await workspace.get("projects", 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 65..74

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

Function createMultistepSelectors has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createMultistepSelectors(stepSelector) {
  return {
    /**
     * .instruction
     */
Severity: Minor
Found in packages/debugger/lib/sourcemapping/selectors/index.js - About 1 hr to fix

    Function deployed has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          deployed: () => {
            let stopText;
            if (reporter.blockSpinner) {
              reporter.blockSpinner.remove();
              stopText = `   > ${reporter.currentBlockWait}`;
    Severity: Minor
    Found in packages/events/defaultSubscribers/migrate/Messages.js - About 1 hr to fix

      Function compileSources has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        compileSources: async function (config, compilers) {
          compilers = config.compiler
            ? config.compiler === "none"
              ? []
              : [config.compiler]
      Severity: Minor
      Found in packages/workflow-compile/legacy/index.js - About 1 hr to fix

        Function link has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          link(name, address) {
            switch (typeof name) {
              case "string":
                // Case: Contract.link(<libraryName>, <address>)
                if (this._json.networks[this.network_id] == null) {
        Severity: Minor
        Found in packages/contract/lib/contract/constructorMethods.js - About 1 hr to fix

          Function sourcesWithDependencies has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async sourcesWithDependencies({ paths = [], options }) {
              options = Config.default().merge(options);
              debug("paths: %O", paths);
              const vyperFilesStrict = paths.filter(path =>
                minimatch(path, VYPER_PATTERN_STRICT, { dot: true })
          Severity: Minor
          Found in packages/compile-vyper/index.js - About 1 hr to fix

            Function printEvents has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              printEvents() {
                const instances = this.session.view(session.info.affectedInstances); //used to look
                const formatAddress = address => {
                  const name = instances[address]?.contractName;
                  const colorizedAddress = colors.yellow(address); //dull yellow
            Severity: Minor
            Found in packages/core/lib/debug/printer.js - About 1 hr to fix

              Function recognizeInteger has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private recognizeInteger(input: unknown): Codec.IntegerWrapResponse {
                  if (Utils.isBigNumber(input)) {
                    if (input.isInteger()) {
                      return {
                        kind: "integer" as const,
              Severity: Minor
              Found in packages/encoder/lib/encoders.ts - About 1 hr to fix

                Function filterProjectNetworkAncestors has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function filterProjectNetworkAncestors(options: {
                  project: IdObject<"projects">;
                  network: DataModel.ResourceNameInput;
                  candidates: IdObject<"networks">[];
                  workspace: Workspace;
                Severity: Minor
                Found in packages/db/src/resources/projects/resolveContractInstances.ts - About 1 hr to fix

                  Function resolver has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        (sources, functions) => breakpoint => {
                          let adjustedBreakpoint;
                          if (breakpoint.node === undefined) {
                            let line = breakpoint.line;
                            if (line < 0) {
                  Severity: Minor
                  Found in packages/debugger/lib/controller/selectors/index.js - About 1 hr to fix

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

                    module.exports = async function (config) {
                      const debugLog = debug.extend("guard");
                      // only check if deploying on MAINNET
                      // NOTE: this includes Ethereum Classic as well as Ethereum as they're only
                      // distinguishable by checking their chainIds, 2 and 1 respectively.
                    Severity: Minor
                    Found in packages/core/lib/commands/migrate/runMigrations.js - About 1 hr to fix

                      Function recognizeAddress has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private async recognizeAddress(
                          input: string
                        ): Promise<Codec.AddressWrapResponse> {
                          let address: string | null = null;
                          try {
                      Severity: Minor
                      Found in packages/encoder/lib/encoders.ts - About 1 hr to fix

                        Function formatCalldata has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          formatCalldata: function (calldata) {
                            //takes a Uint8Array
                            let selector = calldata.slice(0, Codec.Evm.Utils.SELECTOR_SIZE);
                            let words = [];
                            for (
                        Severity: Minor
                        Found in packages/debug-utils/index.js - About 1 hr to fix

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

                                  state.filter(
                                    breakpoint =>
                                      breakpoint.sourceId === action.breakpoint.sourceId &&
                                      breakpoint.line === action.breakpoint.line &&
                                      breakpoint.node === action.breakpoint.node //may be undefined
                          Severity: Major
                          Found in packages/debugger/lib/controller/reducers.js and 1 other location - About 1 hr to fix
                          packages/debugger/lib/controller/reducers.js on lines 29..34

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

                          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

                                return state.filter(
                                  breakpoint =>
                                    breakpoint.sourceId !== action.breakpoint.sourceId ||
                                    breakpoint.line !== action.breakpoint.line ||
                                    breakpoint.node !== action.breakpoint.node //may be undefined
                          Severity: Major
                          Found in packages/debugger/lib/controller/reducers.js and 1 other location - About 1 hr to fix
                          packages/debugger/lib/controller/reducers.js on lines 13..18

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

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

                          export const [
                            isUserDefinedValueTypeValue,
                            isUserDefinedValueTypeErrorResult,
                            isUserDefinedValueTypeResult,
                            userDefinedValueTypeGuards
                          packages/codec-components/src/utils/type-guards/value-and-result/address.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/array.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/bool.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/bytes.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/contract.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/enum.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/fixed.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/int.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/magic.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/mapping.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/options.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/string.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/struct.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/tuple.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/type.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/ufixed.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/uint.ts on lines 4..9

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

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

                          export const [isMagicValue, isMagicErrorResult, isMagicResult, magicGuards] =
                            valueAndResultTypeGuardHelper<
                              Format.Values.MagicValue,
                              Format.Errors.MagicErrorResult,
                              Format.Values.MagicResult
                          packages/codec-components/src/utils/type-guards/value-and-result/address.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/array.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/bool.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/bytes.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/contract.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/enum.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/fixed.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/int.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/mapping.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/options.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/string.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/struct.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/tuple.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/type.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/ufixed.ts on lines 4..13
                          packages/codec-components/src/utils/type-guards/value-and-result/uint.ts on lines 4..9
                          packages/codec-components/src/utils/type-guards/value-and-result/user-defined-value-type.ts on lines 4..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 71.

                          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