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 interface ContractValue {
  type: Types.ContractType;
  kind: "value";
  value: ContractValueInfo;
  interpretations: {
Severity: Major
Found in packages/codec/lib/format/elementary.ts and 1 other location - About 1 hr to fix
packages/codec/lib/format/values.ts on lines 450..457

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

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

  async getExistingStorage(address, slot, blockHash, txIndex) {
    debug("slot: %O", slot);
    const provider = this.web3.currentProvider;
    const hashedSlot = Web3.utils.soliditySha3({
      type: "bytes",
Severity: Minor
Found in packages/debugger/lib/web3/adapter.js - About 1 hr to fix

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

      deployed: async function(options) {
        let files;
        try {
          // Only read JSON files in directory
          files = fs
    Severity: Minor
    Found in packages/core/lib/networks.js - About 1 hr to fix

      Function clone has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        clone(json) {
          json = json || {};
      
          const temp = function TruffleContract() {
            this.constructor = temp;
      Severity: Minor
      Found in packages/contract/lib/contract/constructorMethods.js - About 1 hr to fix

        Function fork has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          fork: async function (config, ganacheOptions) {
            expect.options(config, ["from", "provider", "networks", "network"]);
        
            const interfaceAdapter = createInterfaceAdapter({
              provider: config.provider,
        Severity: Minor
        Found in packages/environment/environment.js - About 1 hr to fix

          Function typeDefs has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            get typeDefs() {
              const log = debug.extend(`${this.resource}:typeDefs`);
              log("Generating...");
          
              const { typeDefs } = this.definition;
          Severity: Minor
          Found in packages/db/src/meta/graph/schema.ts - About 1 hr to fix

            Function collectPairwiseGenealogies has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function collectPairwiseGenealogies<
              Network extends Pick<Resource<"networks">, "id" | "historicBlock">
            >(options: { networks: Network[] }): Input<"networkGenealogies">[] {
              const { networks } = options;
            
            
            Severity: Minor
            Found in packages/db/src/network/load/networkGenealogies.ts - About 1 hr to fix

              Function configure has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const configure = <C extends Config>(options: Options<C>) => {
                const processCollection = configureForCollection(options);
              
                return function* <I extends Input<C>, O extends Output<C>>(options: {
                  project: IdObject<"projects">;
              Severity: Minor
              Found in packages/db/src/project/assignNames/batch.ts - About 1 hr to fix

                Function findYulScopePointer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function findYulScopePointer(node, pointer, base, basePointer) {
                  //walk upward until we find a YulBlock or YulFunctionDefinition,
                  //with a special case for YulForLoop
                  debug("pointer: %s", pointer);
                  debug("basePointer: %s", basePointer);
                Severity: Minor
                Found in packages/debugger/lib/ast/sagas/index.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 callstack has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function callstack(state = [], action) {
                  let newFrame;
                  switch (action.type) {
                    case actions.JUMP_IN:
                      const {
                Severity: Minor
                Found in packages/debugger/lib/stacktrace/reducers.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 instantCreate has 10 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  pointer,
                  newPointer, //does not actually affect the current pointer!
                  step,
                  address,
                  context,
                Severity: Major
                Found in packages/debugger/lib/txlog/actions/index.js - About 1 hr to fix

                  Function state has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          (allAllocations, compilationId, { isConstructor }) => {
                            debug("compilationId: %s", compilationId);
                            debug("allAllocations: %o", allAllocations);
                            const allocations = compilationId
                              ? allAllocations[compilationId]
                  Severity: Minor
                  Found in packages/debugger/lib/data/selectors/index.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 callKind has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function callKind(context, calldata, instant) {
                    if (context) {
                      if (context.contractKind === "library") {
                        return instant ? "message" : "library";
                        //for an instant return, just get it out of the way and set it to
                  Severity: Minor
                  Found in packages/debugger/lib/txlog/sagas/index.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 generateReport has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function generateReport(rawStack, location, status, message) {
                    //step 1: process combined frames
                    let callstack = [];
                    //we're doing a C-style loop here!
                    //because we want to skip some items <grin>
                  Severity: Minor
                  Found in packages/debugger/lib/stacktrace/selectors/index.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 _extract has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _extract: function (res, web3, _interfaceAdapter) {
                      //I'm not sure why interfaceAdapter is here if it's not used,
                      //so I just put an underscore in front of its name for now...
                      if (!res || (!res.error && !res.result)) return;
                  
                  
                  Severity: Minor
                  Found in packages/contract/lib/reason.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 getHumanReadableSourceMap has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    getHumanReadableSourceMap: function (sourceMap) {
                      const instructions = sourceMap.split(";");
                  
                      let processedInstruction = {
                        start: 0,
                  Severity: Minor
                  Found in packages/source-map-utils/index.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 setOrClearBreakpointObject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    async setOrClearBreakpointObject(breakpoint, setOrClear) {
                      const existingBreakpoints = this.session.view(controller.breakpoints);
                      //OK, we've constructed the breakpoint!  But if we're adding, we'll
                      //want to adjust to make sure we don't set it on an empty line or
                      //anything like that
                  Severity: Minor
                  Found in packages/core/lib/debug/interpreter.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 abiParameterToType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function abiParameterToType(abi: Parameter): Format.Types.Type {
                    let typeName = abi.type;
                    let typeHint = abi.internalType;
                    //first: is it an array?
                    let arrayMatch = typeName.match(/(.*)\[(\d*)\]$/);
                  Severity: Minor
                  Found in packages/codec/lib/abi-data/import/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 needsMigrating has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    needsMigrating: function (options: Config) {
                      return new Promise((resolve, reject) => {
                        if (options.reset === true) return resolve(true);
                  
                        return this.lastCompletedMigration(options)
                  Severity: Minor
                  Found in packages/migrate/src/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 reportSources has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const reportSources = ({ paths, options }) => {
                    if (options.quiet !== true && options.events) {
                      if (!Array.isArray(paths)) {
                        paths = Object.keys(paths);
                      }
                  Severity: Minor
                  Found in packages/compile-solidity/src/reportSources.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

                  Severity
                  Category
                  Status
                  Source
                  Language