trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

Function decodeLiteral has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export function* decodeLiteral(
  dataType: Format.Types.Type,
  pointer: Pointer.StackLiteralPointer,
  info: Evm.EvmInfo
): Generator<DecoderRequest, Format.Values.Result, Uint8Array | null> {
Severity: Minor
Found in packages/codec/lib/stack/decode/index.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 deriveConfigEnvironment has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deriveConfigEnvironment = function (detectedConfig, network, url) {
  let configuredNetwork;

  const configDefinesProvider =
    detectedConfig.networks[network] &&
Severity: Minor
Found in packages/core/lib/command-utils.js - About 1 hr to fix

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

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

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

      module.exports = async options => {
        const TruffleError = require("@truffle/error");
        const { Plugins } = require("@truffle/plugins");
        const { getConfig, constructRecipes } = require("./plugins");
        const { preserve, ConsoleReporter } = require("@truffle/preserve");
      Severity: Minor
      Found in packages/core/lib/commands/preserve/run.js - About 1 hr to fix

        Function readStorage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function* readStorage(
          pointer: Pointer.StoragePointer,
          state: Evm.EvmState
        ): Generator<DecoderRequest, Uint8Array, Uint8Array | null> {
          const { storage } = state;
        Severity: Minor
        Found in packages/codec/lib/storage/read/index.ts - About 1 hr to fix

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

          export function* process(options: {
            relationship: "ancestor" | "descendant";
            network: IdObject<"networks">;
            alreadyTried: string[];
            disableIndex?: boolean;
          Severity: Minor
          Found in packages/db/src/network/query/nextPossiblyRelatedNetworks.ts - About 1 hr to fix

            Function forAttachAndSchema has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const forAttachAndSchema = <C extends Collections>(options: {
              attach: (options: Pouch.Adapters.AttachOptions) => Workspace<C>;
              schema: GraphQLSchema;
            }) => {
              const { attach, schema } = options;
            Severity: Minor
            Found in packages/db/src/meta/interface.ts - About 1 hr to fix

              Function decodeDispatch has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function* decodeDispatch(
                dataType: Format.Types.Type,
                pointer: Pointer.DataPointer,
                info: Evm.EvmInfo,
                options: DecoderOptions = {}
              Severity: Minor
              Found in packages/codec/lib/decode.ts - About 1 hr to fix

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

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

                  Function _ has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          (scopes, scope, pointer, sourceId, language) => {
                            let variables = {};
                            if (scope !== undefined) {
                              let cur =
                                scope.id !== undefined ? scope.id : makePath(sourceId, pointer);
                  Severity: Minor
                  Found in packages/debugger/lib/data/selectors/index.js - About 1 hr to fix

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

                    module.exports = async function (options) {
                      const TruffleError = require("@truffle/error");
                      const WorkflowCompile = require("@truffle/workflow-compile").default;
                      const Config = require("@truffle/config");
                      const config = Config.detect(options);
                    Severity: Minor
                    Found in packages/core/lib/commands/compile/run.js - About 1 hr to fix

                      Function execVyper has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function execVyper(options, sourcePath, version, callback) {
                        const formats = ["abi", "bytecode", "bytecode_runtime"];
                        debug("version: %s", version);
                        if (
                          semver.satisfies(version, ">=0.1.0-beta.7", {
                      Severity: Minor
                      Found in packages/compile-vyper/index.js - About 1 hr to fix

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

                        module.exports = async function (selectedCommand, subCommand, options) {
                          const commands = require("../index");
                          const globalCommandOptions = require("../../global-command-options");
                          const TruffleError = require("@truffle/error");
                        
                        
                        Severity: Minor
                        Found in packages/core/lib/commands/help/displayCommandHelp.js - About 1 hr to fix

                          Function decodeReturnValueWithAdditionalContexts has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            public async decodeReturnValueWithAdditionalContexts(
                              abi: Abi.FunctionEntry,
                              data: string,
                              options: DecoderTypes.ReturnOptions = {},
                              additionalContexts: Contexts.Contexts = {}
                          Severity: Minor
                          Found in packages/decoder/lib/decoders.ts - About 1 hr to fix

                            Function constructor has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              constructor(info: Types.EncoderInfoInternal) {
                                //first, set up the basic info that we need to run
                                if (info.userDefinedTypes && info.allocations) {
                                  debug("internal route!");
                                  this.userDefinedTypes = info.userDefinedTypes;
                            Severity: Minor
                            Found in packages/encoder/lib/encoders.ts - About 1 hr to fix

                              Function decodeMessage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export async function decodeMessage(
                                lifecycle: ReceivedMessageLifecycle<DashboardProviderMessage>,
                                decoder: ProjectDecoder
                              ) {
                                const method = lifecycle.message.payload.method as DecodableRpcMethod;
                              Severity: Minor
                              Found in packages/dashboard/src/utils/dash.ts - About 1 hr to fix

                                Function handleCompilations has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    async (compilations: Compilation[], hashes?: string[]) => {
                                      if (compilations.length === 0 || !stateRef.current.decoder) return;
                                
                                      let decoderNeedsUpdate = false;
                                      const decoderCompilations = [...stateRef.current.decoderCompilations!];
                                Severity: Minor
                                Found in packages/dashboard/src/contexts/DashContext/DashProvider.tsx - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                          if (
                                            isContextChange ||
                                            !node ||
                                            node.id === undefined ||
                                            !next ||
                                  Severity: Critical
                                  Found in packages/debugger/lib/data/selectors/index.js - About 1 hr to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                        if (
                                          decoding.kind === "function" &&
                                          (decoding.abi.name === "aggregate" ||
                                            decoding.abi.name === "blockAndAggregate") &&
                                          decoding.abi.inputs.length === 1 &&
                                    Severity: Critical
                                    Found in packages/decoder/lib/decoders.ts - About 1 hr to fix

                                      Consider simplifying this complex logical expression.
                                      Open

                                          } else if (
                                            decoding.kind === "function" &&
                                            decoding.abi.name === "aggregate3" &&
                                            decoding.abi.inputs.length === 1 &&
                                            decoding.abi.inputs[0].type === "tuple[]" &&
                                      Severity: Critical
                                      Found in packages/decoder/lib/decoders.ts - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language