NaturalIntelligence/Stubmatic

View on GitHub

Showing 54 of 106 total issues

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

exports.evaluate = function(exp,rc,store){

    if(isFunction(exp)){
        var fExp = buildFunctionExp(exp);
        for (var i = 0; i < fExp.args.length; i++) {
Severity: Minor
Found in lib/expressions/engine.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 exports has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(data, mappedEntry, source){
    var regx = "{{\\s*(.*)\\s*}}";
    var expressions = util.getAllMatches(data,regx);
    var dataTableRegex = "#(([\\w]+)|(([\\w]+)(\\[\\s*([0-9]+)\\s*\\])?)(\\((.*?)\\))?\.([\\w]+))";
    for(var i in expressions){
Severity: Minor
Found in lib/expressions/dataTableExpression.js - About 1 hr to fix

    Function matchParamters has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function matchParamters(http_request, mapped_request, param_name){
        var clips = [];
        clips[0] = "N/A";
        if( !http_request[param_name]){
            if( mapped_request[param_name] ){
    Severity: Minor
    Found in lib/RequestResolver.js - About 1 hr to fix

      Function convertToFullNotationIfShort has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function convertToFullNotationIfShort(mapping){
          if(mapping.request){
              return mapping;
          }else{
              var fullNotation ={};
      Severity: Minor
      Found in lib/loaders/MappingsBuilder.js - About 1 hr to fix

        Function getFileName has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getFileName (matchedentry) {
                var res = matchedentry.response,
                    matches = matchedentry.request.matches;
            
                if (res.file) {
        Severity: Minor
        Found in lib/FileStrategyHandler.js - About 1 hr to fix

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

          module.exports = function (data, dumpsdir, store, requestMatches){
              //var regx = "\\[\\[([^\\]]+)\\]\\]";
              var regx = "{{\\s*include\\(([^}]*)\\)\\s*}}";
              var matches = util.getAllMatches(data,regx);
              
          Severity: Minor
          Found in lib/expressions/includeFileExpression.js - About 1 hr to fix

            Function convertToFullNotationIfShort has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function convertToFullNotationIfShort(mapping){
                if(mapping.request){
                    return mapping;
                }else{
                    var fullNotation ={};
            Severity: Minor
            Found in lib/loaders/MappingsBuilder.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 getEncodingStream has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function getEncodingStream(encodingHeader, response, dataStream){
                let encodingName = encodingHeader;
                if(encodingName === "*"){
                    encodingName = "gzip";
                }
            Severity: Minor
            Found in lib/compressionHandler.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 buildMappingFileContent has 26 lines of code (exceeds 25 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 1 hr to fix

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

                  _buildFromDirectory(dirPath){
                      this.config.datatables = joinPathIfExists(dirPath, "datatables");
                      this.config.stubs = joinPathIfExists(dirPath, "stubs");
                      this.config.dumps = joinPathIfExists(dirPath, "dumps");
                      this.config.recordAndPlay.path = joinPathIfExists(dirPath, "recordings");
              Severity: Minor
              Found in lib/ConfigBuilder.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 (res.strategy.indexOf("random") > -1) {
                                      return this.getRandomFirstFound(res, matchedentry, matches);
                                  } else if (res.strategy.indexOf("round-robin") > -1) {
                                      return this.getRoundRobinFirstFound(res, matchedentry, matches,matchedentry.index);
                                  }
              Severity: Major
              Found in lib/FileStrategyHandler.js - About 45 mins to fix

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

                    evaluate : function(result){
                        var today = exports.now();
                        for(var i = 1; i < result.length; i++) {
                            var match = result[i];
                
                
                Severity: Minor
                Found in lib/markers.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 deeply nested control flow statements.
                Open

                                            if(fileLevelMappings[i].response && fileLevelMappings[i].response.parser && typeof fileLevelMappings[i].response.parser === "string"){
                                                fileLevelMappings[i].response.parser = {
                                                    type : fileLevelMappings[i].response.parser
                                                };
                                            }
                Severity: Major
                Found in lib/loaders/MappingsBuilder.js - About 45 mins to fix

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

                          evaluate : function(result){
                          var today = exports.nowJoda();
                          for(var i = 1; i < result.length; i++) {
                              var match = result[i];
                  
                  
                  Severity: Minor
                  Found in lib/markers.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

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

                  function validateSyntax(fileName) {
                      try {
                          if (fileName.endsWith(".json")) {
                              require('jsonlint').parse(fs.readFileSync(fileName, {
                                  encoding: 'utf-8'
                  Severity: Minor
                  Found in index.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 deeply nested control flow statements.
                  Open

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

                    Avoid deeply nested control flow statements.
                    Open

                                    if(matches && matches.length > 1){
                                        matches = matches.slice(1);
                                        clips = clips.concat(matches);
                                    }
                    Severity: Major
                    Found in lib/RequestResolver.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if (key === '--port' || key === '-p') {
                                          key = '-p';
                                      } else if (key === '--config' || key === '-c') {
                                          key = '-c';
                                      } else if (key === '--host' || key === '-P' || key === '--mutualSSL') {
                      Severity: Major
                      Found in index.js - About 45 mins to fix

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

                        module.exports = function(response, responseRecieved, fileName){
                            let encodingName = responseRecieved.headers["content-encoding"];
                            if(encodingName){
                                let encodingStream = supportedEncodings[ encodingName ];//when only one encoding name is given
                                if( !encodingStream ){//when multiple encoding schems are acceptable 
                        Severity: Minor
                        Found in lib/proxyResponseHandler.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

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

                            _updateBasePath(basePath){
                        
                                this.config.datatables = joinPath(basePath , this.config.datatables);
                                this.config.stubs = joinPath(basePath , this.config.stubs);
                                this.config.dumps = joinPath(basePath , this.config.dumps);
                        Severity: Minor
                        Found in lib/ConfigBuilder.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

                        Severity
                        Category
                        Status
                        Source
                        Language