NaturalIntelligence/Stubmatic

View on GitHub

Showing 54 of 106 total issues

Function redirect has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function redirect(request, response, requestProcessor, baseUrl, options){
Severity: Minor
Found in lib/server.js - About 35 mins to fix

    Function cli has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function cli(args) {
        if (args[2] === "--help" || args[2] === "-h") {
            console.log(fs.readFileSync(__dirname + "/man/stubmatic.1", 'utf-8'));
        } else if (args[2] === "--version") {
            console.log(require(__dirname + "/package.json").version);
    Severity: Minor
    Found in index.js - About 35 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

    Function assignPath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function assignPath(originalPath, basePaths){
        if(fileutil.isExist(originalPath)){
            return originalPath;
        }else{
            for(let i=0; i< basePaths.length; i++){
    Severity: Minor
    Found in lib/FileStrategyHandler.js - About 35 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

    Function resolveDBSetKey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    var resolveDBSetKey = function (table, tables){
        if(table.key){
            var row = tables[table.name].get(table.key);
            if(row){
                return table.key;
    Severity: Minor
    Found in lib/expressions/dataTableExpression.js - About 35 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

    Function resolveDBSetKey has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    var resolveDBSetKey = function (table, tables){
        if(table.key){
            var row = tables[table.name].get(table.key);
            if(row){
                return table.key;
    Severity: Minor
    Found in lib/RequestResolver.js - About 35 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;
    Severity: Major
    Found in lib/RequestResolver.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  else            return;
      Severity: Major
      Found in lib/RequestResolver.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                return this.getRoundRobinFirstFound(res, matchedentry, matches,matchedentry.index);
        Severity: Major
        Found in lib/FileStrategyHandler.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                                  return this.getRandomFirstFound(res, matchedentry, matches);
          Severity: Major
          Found in lib/FileStrategyHandler.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            if(!matches) return;
            Severity: Major
            Found in lib/RequestResolver.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return matched;
              Severity: Major
              Found in lib/RequestResolver.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return clips;
                Severity: Major
                Found in lib/RequestResolver.js - About 30 mins to fix

                  Function buildMappingFileContent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function buildMappingFileContent(req,res, options){
                      const mappingFileContent = {
                          request: {
                              method: req.method,
                              url: req.url,
                  Severity: Minor
                  Found in lib/server.js - About 25 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

                  Function buildSecureServerConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function buildSecureServerConfig(config){
                      let options = {};
                  
                      if( config.server.key && config.server.cert ){
                          options = {
                  Severity: Minor
                  Found in lib/ConfigBuilder.js - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language