trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

Function reducer has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export const reducer = (state: State, action: Action): State => {
  const { type, data } = action;
  switch (type) {
    case "set-decoder":
      return { ...state, ...data };
Severity: Minor
Found in packages/dashboard/src/contexts/DashContext/state.ts - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function display has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

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

      DebugUtils has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      var DebugUtils = {
        truffleColors, //make these externally available
      
        //panicCode may be either a number, BN, or decimal string
        panicString: function (panicCode, verbose = false) {
      Severity: Minor
      Found in packages/debug-utils/index.js - About 3 hrs to fix

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

        export const normalizeSourcePath = (url = defaultPath) => {
          // Process filepath resolution
          //
          if (url.startsWith(".") || url.startsWith("/") || url.startsWith("~")) {
            debug({ in: url, out: path.normalize(url) });
        Severity: Major
        Found in packages/box/box.ts - About 3 hrs to fix

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

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

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

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

              Function mappedPaths has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function markTextHighlighted has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function markTextHighlighted(source: Source, sourceRange: SourceRange) {
                  const fullyHighlightedLines = new Set<number>();
                  const editedLines = source.contents.split("\n").map((line, index) => {
                    if (line.length === 0) {
                      return line;

                  Function resolve has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                    async resolve(
                      importModule: string,
                      importedFrom: string,
                      options: { compiler?: { name: string } } = {}
                    ) {
                  Severity: Minor
                  Found in packages/resolver/lib/sources/vyper.ts - About 2 hrs to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  File sourcify.ts has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import debugModule from "debug";
                  const debug = debugModule("source-fetcher:sourcify");
                  
                  import type { Fetcher, FetcherConstructor } from "./types";
                  import type * as Types from "./types";
                  Severity: Minor
                  Found in packages/source-fetcher/lib/sourcify.ts - About 2 hrs to fix

                    Function Variables has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function Variables(): JSX.Element | null {
                      const { classes } = useStyles();
                      const {
                        state: {
                          debugger: { session }
                    Severity: Major
                    Found in packages/dashboard/src/components/composed/Debugger/Variables.tsx - About 2 hrs to fix

                      Function tryFetchAndCompileAddress has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function tryFetchAndCompileAddress(
                        address: string,
                        fetchers: Fetcher[],
                        recognizer: Recognizer,
                        fetchAndCompileOptions: FetchAndCompileOptions
                      Severity: Major
                      Found in packages/fetch-and-compile/lib/fetch.ts - About 2 hrs to fix

                        Function stacktraceSaga has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function* stacktraceSaga() {
                          const currentLocation = yield select(stacktrace.current.strippedLocation);
                          const lastLocation = yield select(stacktrace.current.lastPosition);
                          const returnCounter = yield select(stacktrace.current.returnCounter);
                          let positionUpdated = false;
                        Severity: Major
                        Found in packages/debugger/lib/stacktrace/sagas/index.js - About 2 hrs to fix

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

                          module.exports = async function (options) {
                            const OS = require("os");
                            const { promisify } = require("util");
                            const loadConfig = require("../../loadConfig");
                            const { Environment } = require("@truffle/environment");
                          Severity: Major
                          Found in packages/core/lib/commands/debug/run.js - About 2 hrs to fix

                            File schema.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import { logger } from "@truffle/db/logger";
                            const debug = logger("db:meta:graph:schema");
                            
                            import gql from "graphql-tag";
                            import type * as graphql from "graphql";
                            Severity: Minor
                            Found in packages/db/src/meta/graph/schema.ts - About 2 hrs to fix

                              Function continueUntilBreakpoint has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function* continueUntilBreakpoint(action) {
                                //if breakpoints was not specified, use the stored list from the state.
                                //if it was, override that with the specified list.
                                //note that explicitly specifying an empty list will advance to the end.
                                let breakpoints =
                              Severity: Major
                              Found in packages/debugger/lib/controller/sagas/index.js - About 2 hrs to fix

                                Function interpretCallInAggregate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  private async interpretCallInAggregate(
                                    callResult: Format.Values.StructResult | Format.Values.TupleResult,
                                    transaction: DecoderTypes.Transaction,
                                    additionalContexts: Contexts.Contexts = {},
                                    additionalAllocations?: {
                                Severity: Minor
                                Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

                                Cognitive Complexity

                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                A method's cognitive complexity is based on a few simple rules:

                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                • Code is considered more complex for each "break in the linear flow of the code"
                                • Code is considered more complex when "flow breaking structures are nested"

                                Further reading

                                Function run has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export async function run(
                                  rawSources: { [name: string]: string },
                                  options: Config,
                                  internalOptions: InternalOptions = {}
                                ): Promise<Compilation | null> {
                                Severity: Major
                                Found in packages/compile-solidity/src/run.ts - About 2 hrs to fix

                                  Function resolve has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    async resolve(
                                      importModule: string,
                                      importedFrom: string,
                                      options: { compiler?: { name: string } } = {}
                                    ) {
                                  Severity: Major
                                  Found in packages/resolver/lib/sources/vyper.ts - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language