FrenchYeti/dexcalibur

View on GitHub
inspectors/BytecodeCleaner/service/main.js

Summary

Maintainability
F
1 wk
Test Coverage

Function moveBasicBlock has a Cognitive Complexity of 121 (exceeds 5 allowed). Consider refactoring.
Open

function moveBasicBlock(method, bblocks, gotoLabel){
    //console.log("Moving basic blocks "+bblocks.offset+"(len:"+bblocks.blk.length+") at instr goto_"+gotoLabel);
    let bbs = [], flag=false, lastWasGoto=false, endbb=0, tmp=null;
    // find cut point
    if( method.instr != null && method.instr.length > 0){
Severity: Minor
Found in inspectors/BytecodeCleaner/service/main.js - About 2 days 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 main.js has 459 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const IFC = require("../../../src/InspectorFrontController.js");
var CONST = require("../../../src/CoreConst.js");
const Disassembler = require("../../../src/Disassembler.js");

var Controller =  new IFC.FrontController();
Severity: Minor
Found in inspectors/BytecodeCleaner/service/main.js - About 7 hrs to fix

    Function findTargetBasicBlocks has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    function findTargetBasicBlocks(method, gotoLabel){
        //console.log("Searching block at :goto_"+gotoLabel);
        let targetBBs = null, found=false, offset=0, duplicate=false;
        if( method.instr != null && method.instr.length > 0){
            for(let i=0; i<method.instr.length ; i++){
    Severity: Minor
    Found in inspectors/BytecodeCleaner/service/main.js - About 6 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 moveBasicBlock has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function moveBasicBlock(method, bblocks, gotoLabel){
        //console.log("Moving basic blocks "+bblocks.offset+"(len:"+bblocks.blk.length+") at instr goto_"+gotoLabel);
        let bbs = [], flag=false, lastWasGoto=false, endbb=0, tmp=null;
        // find cut point
        if( method.instr != null && method.instr.length > 0){
    Severity: Major
    Found in inspectors/BytecodeCleaner/service/main.js - About 2 hrs to fix

      Function flatternGotoOf has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function flatternGotoOf(method){
      
          let blocksToMove = null;
          let singleGoto = findSingleGoto(method);
          let ret = false;
      Severity: Minor
      Found in inspectors/BytecodeCleaner/service/main.js - 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 findSingleGoto has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function findSingleGoto(method){
          let found = {}, singles = [];
          
      
          // count GOTOs
      Severity: Minor
      Found in inspectors/BytecodeCleaner/service/main.js - 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 nextSingleGoto has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function nextSingleGoto(method){
          let found = {}, singles = [];
          
      
          // count GOTOs
      Severity: Minor
      Found in inspectors/BytecodeCleaner/service/main.js - 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 gotoLocalXref has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      function gotoLocalXref(method,goto_name){
          let xref = {
              name: null,
              ref: [],
              ctr: 0 
      Severity: Minor
      Found in inspectors/BytecodeCleaner/service/main.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 findTargetBasicBlocks has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function findTargetBasicBlocks(method, gotoLabel){
          //console.log("Searching block at :goto_"+gotoLabel);
          let targetBBs = null, found=false, offset=0, duplicate=false;
          if( method.instr != null && method.instr.length > 0){
              for(let i=0; i<method.instr.length ; i++){
      Severity: Minor
      Found in inspectors/BytecodeCleaner/service/main.js - About 1 hr to fix

        Function checkIfEligible has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function checkIfEligible(method){
        
            let notElgible = [
                CONST.INSTR_TYPE.IF,
                CONST.INSTR_TYPE.SWITCH,
        Severity: Minor
        Found in inspectors/BytecodeCleaner/service/main.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 renameStaticInterface has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function renameStaticInterface(database, method, pContext){
        
            if(!hasSingleCall(method)) return false;
            if(method.args.length==0) return false;
        
        
        Severity: Minor
        Found in inspectors/BytecodeCleaner/service/main.js - About 1 hr to fix

          Function flatternGotoOf has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function flatternGotoOf(method){
          
              let blocksToMove = null;
              let singleGoto = findSingleGoto(method);
              let ret = false;
          Severity: Minor
          Found in inspectors/BytecodeCleaner/service/main.js - About 1 hr to fix

            Function renameStaticInterface has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            function renameStaticInterface(database, method, pContext){
            
                if(!hasSingleCall(method)) return false;
                if(method.args.length==0) return false;
            
            
            Severity: Minor
            Found in inspectors/BytecodeCleaner/service/main.js - About 55 mins 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

            Avoid deeply nested control flow statements.
            Open

                            if(method.instr[i].hasInstr(CONST.INSTR_TYPE.RET))
                                duplicate = true;
            Severity: Major
            Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if(found[instruction.right.name]===undefined)
                                      found[instruction.right.name]=1;
                                  else
                                      found[instruction.right.name]+=1;
              Severity: Major
              Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    else if(lastWasGoto){
                                        if(instruction.opcode.type !== CONST.INSTR_TYPE.NOP){
                                            console.log("[ERROR] CFG changed !!!");
                                        }
                                    }
                Severity: Major
                Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  if(hasJump(method.instr[i].stack)){
                                      if(DEBUG) console.log("block has jump POST :",gotoLabel,targetBBs[targetBBs.length-1].stack);
                                      break;
                                  } 
                  Severity: Major
                  Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if(instruction.right.name == gotoLabel){
                    
                                                //console.log(bblocks);
                    
                    
                    
                    Severity: Major
                    Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if(found[instruction.right.name]===undefined)
                                              found[instruction.right.name]=1;
                                          else
                                              found[instruction.right.name]+=1;
                      Severity: Major
                      Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if(DEBUG) console.log("block has jump :",method.instr[i].goto_name,gotoLabel,targetBBs);
                        Severity: Major
                        Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if(j !== method.instr[i].stack.length-1){
                                                  console.log(method.signature(),"[:goto_"+goto_name,"] Not the last instruction")
                                              }
                          Severity: Major
                          Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins to fix

                            Function renameDoubleStatic has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function renameDoubleStatic(database, method, pContext){
                            
                                if(!hasSingleCall(method)) return false;
                            
                            
                            
                            Severity: Minor
                            Found in inspectors/BytecodeCleaner/service/main.js - About 45 mins 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

                            Avoid too many return statements within this function.
                            Open

                                return true;
                            Severity: Major
                            Found in inspectors/BytecodeCleaner/service/main.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return false;
                              Severity: Major
                              Found in inspectors/BytecodeCleaner/service/main.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return true;
                                Severity: Major
                                Found in inspectors/BytecodeCleaner/service/main.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      if(paramOnly === false) return false;
                                  Severity: Major
                                  Found in inspectors/BytecodeCleaner/service/main.js - About 30 mins to fix

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

                                            args.map( pLocation => {
                                                let instr = method.getInstr(pLocation.bb,pLocation.instr);
                                                if(instr != null){
                                                    instr.left.map( vParam => {
                                                        if(vParam.t !== CONST.LEX.TOKEN.PARAM) paramOnly = false;
                                    Severity: Major
                                    Found in inspectors/BytecodeCleaner/service/main.js and 1 other location - About 2 hrs to fix
                                    inspectors/BytecodeCleaner/service/main.js on lines 572..579

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

                                    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

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

                                            args.map( pLocation => {
                                                let instr = method.getInstr(pLocation.bb,pLocation.instr);
                                                if(instr != null){
                                                    instr.left.map( vParam => {
                                                        if(vParam.t !== CONST.LEX.TOKEN.PARAM) paramOnly = false;
                                    Severity: Major
                                    Found in inspectors/BytecodeCleaner/service/main.js and 1 other location - About 2 hrs to fix
                                    inspectors/BytecodeCleaner/service/main.js on lines 644..651

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

                                    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

                                    There are no issues that match your filters.

                                    Category
                                    Status