trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

Function DashProvider has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

function DashProvider({ children }: DashProviderProps): JSX.Element {
  const { isConnected, address } = useAccount();
  const { chain } = useNetwork();
  const [state, dispatch] = useReducer(reducer, initialState);
  const initCalled = useRef(false);
Severity: Minor
Found in packages/dashboard/src/contexts/DashContext/DashProvider.tsx - About 5 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 console.js has 388 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const repl = require("repl");
const provision = require("@truffle/provisioner");
const {
  Web3Shim,
  createInterfaceAdapter
Severity: Minor
Found in packages/core/lib/console.js - About 5 hrs to fix

    File execute.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const debug = require("debug")("contract:execute");
    const PromiEvent = require("./promievent");
    const EventEmitter = require("events");
    const utils = require("./utils");
    const StatusError = require("./statuserror");
    Severity: Minor
    Found in packages/contract/lib/execute.js - About 5 hrs to fix

      Function printReturnValue has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

        async printReturnValue() {
          //note: when printing revert messages, this will do so in a somewhat
          //different way than printRevertMessage does
          const inspectOptions = {
            colors: true,
      Severity: Minor
      Found in packages/core/lib/debug/printer.js - About 5 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 codex has 127 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function codex(state = DEFAULT_CODEX, action) {
        let newState, topCodex, topCodexNoZero;
      
        const updateFrameStorage = (frame, address, slot, value) => ({
          ...frame,
      Severity: Major
      Found in packages/debugger/lib/evm/reducers.js - About 5 hrs to fix

        Function determineBreakpoints has 126 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          determineBreakpoints(args) {
            const currentLocation = this.session.view(controller.current.location);
        
            const currentStart = currentLocation.sourceRange
              ? currentLocation.sourceRange.start
        Severity: Major
        Found in packages/core/lib/debug/interpreter.js - About 5 hrs to fix

          Function init has 126 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public async init(): Promise<void> {
              this.contractCode = Conversion.toHexString(
                await this.getCode(
                  this.contractAddress,
                  await this.providerAdapter.getBlockNumber() //not "latest" because regularized
          Severity: Major
          Found in packages/decoder/lib/decoders.ts - About 5 hrs to fix

            Function connect has 120 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async connect(): Promise<void> {
                if (this._socket) {
                  switch (this._socket.readyState) {
                    case WebSocket.CONNECTING:
                      debug(
            Severity: Major
            Found in packages/dashboard-message-bus-client/lib/connection/index.ts - About 4 hrs to fix

              Function requiredSources has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function requiredSources({
                allPaths,
                updatedPaths,
                resolve,
                shouldIncludePath,
              Severity: Minor
              Found in packages/profiler/src/requiredSources.ts - About 4 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 properties.js has 364 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const utils = require("../utils");
              const web3Utils = require("web3-utils");
              
              module.exports = {
                contract_name: {
              Severity: Minor
              Found in packages/contract/lib/contract/properties.js - About 4 hrs to fix

                ProjectDecoder has 35 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class ProjectDecoder {
                  private providerAdapter: ProviderAdapter;
                
                  private compilations: Compilations.Compilation[];
                  private contexts: Contexts.Contexts = {}; //all contexts
                Severity: Minor
                Found in packages/decoder/lib/decoders.ts - About 4 hrs to fix

                  Function decodeMagic has 112 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function* decodeMagic(
                    dataType: Format.Types.MagicType,
                    pointer: Pointer.SpecialPointer,
                    info: Evm.EvmInfo
                  ): Generator<DecoderRequest, Format.Values.MagicResult, Uint8Array | null> {
                  Severity: Major
                  Found in packages/codec/lib/special/decode/index.ts - About 4 hrs to fix

                    Function isDesignatedInvalid has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      isDesignatedInvalid: function (
                        instructions,
                        index,
                        overlapFunctions,
                        node = undefined
                    Severity: Major
                    Found in packages/source-map-utils/index.js - About 4 hrs to fix

                      Function reducer has 111 lines of code (exceeds 25 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: Major
                      Found in packages/dashboard/src/contexts/DashContext/state.ts - About 4 hrs to fix

                        Function determineBreakpoints has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                        Open

                          determineBreakpoints(args) {
                            const currentLocation = this.session.view(controller.current.location);
                        
                            const currentStart = currentLocation.sourceRange
                              ? currentLocation.sourceRange.start
                        Severity: Minor
                        Found in packages/core/lib/debug/interpreter.js - About 4 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 typeStringWithoutLocation has 110 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function typeStringWithoutLocation(dataType: Format.Types.Type): string {
                          switch (dataType.typeClass) {
                            case "uint":
                              return dataType.typeHint || `uint${dataType.bits}`;
                            case "int":
                        Severity: Major
                        Found in packages/codec-components/src/utils/codec.ts - About 4 hrs to fix

                          Function Contract has 109 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function Contract(contract) {
                              var instance = this;
                              var constructor = instance.constructor;
                          
                              // Disambiguate between .at() and .new()
                          Severity: Major
                          Found in packages/contract/lib/contract/index.js - About 4 hrs to fix

                            Session has 34 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            export default class Session {
                              /**
                               * @param {Array<Compilations>} compilations
                               * @param {Web3Provider} provider - web3 provider
                               * txHash parameter is now optional!
                            Severity: Minor
                            Found in packages/debugger/lib/session/index.js - About 4 hrs to fix

                              File reducers.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import debugModule from "debug";
                              const debug = debugModule("debugger:evm:reducers");
                              
                              import { combineReducers } from "redux";
                              
                              
                              Severity: Minor
                              Found in packages/debugger/lib/evm/reducers.js - About 4 hrs to fix

                                File Messages.js has 341 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                /**
                                 *  A module that formats output for the Migrations reporter.
                                 */
                                class Messages {
                                  constructor(reporter) {
                                Severity: Minor
                                Found in packages/events/defaultSubscribers/migrate/Messages.js - About 4 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language