NaturalIntelligence/Stubmatic

View on GitHub

Showing 54 of 106 total issues

Function matchParamters has a Cognitive Complexity of 32 (exceeds 5 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 4 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 buildMappings has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    buildMappings(mappingFiles, allMappings){
        var fileLevelMappings;
        allMappings = allMappings || [];
        //defaultConfig = config.mappings.default || defaultConfig;
        defaultConfig = deepAssign({},defaultConfig, this.options.mappings.default);
Severity: Minor
Found in lib/loaders/MappingsBuilder.js - About 4 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 buildServerOptions has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

function buildServerOptions(args) {
    var options = {};
    for (var i = 2; i < args.length; i++) {
        if (args[i].indexOf("-") === 0) {
            var key = args[i];
Severity: Minor
Found in index.js - About 3 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 process has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    process(request, response, onSuccess, onError){
        
        var rc = new RequestContext(request);
        logger.info(rc.getTransactionId() + " " + request.method+": "+request.url,'green');

Severity: Minor
Found in lib/RequestProcessor.js - About 3 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 getFileName has a Cognitive Complexity of 22 (exceeds 5 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 3 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 exports has a Cognitive Complexity of 21 (exceeds 5 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 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 matchAndCapture has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function matchAndCapture(mapped_request, http_request){
    var matched = {}, i=0;

    if(Array.isArray(mapped_request.method)){
        if(mapped_request.method.indexOf(http_request.method) === -1) return;
Severity: Minor
Found in lib/RequestResolver.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 process has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    process(request, response, onSuccess, onError){
        
        var rc = new RequestContext(request);
        logger.info(rc.getTransactionId() + " " + request.method+": "+request.url,'green');

Severity: Major
Found in lib/RequestProcessor.js - About 2 hrs to fix

    Function exports has a Cognitive Complexity of 15 (exceeds 5 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

    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 parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        parse(http_request, mappings, dataTables){
            for(var i=0;i<mappings.length;i++){
                var entry = util.clone(mappings[i]);
                var matched = matchAndCapture(entry.request, http_request);
                if(matched){//if nothing matches in current mapping, check for other matching
    Severity: Minor
    Found in lib/RequestResolver.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 build has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        build(options){
            this.config = {
                mappings: {},
                server:{},
                recordAndPlay : {
    Severity: Minor
    Found in lib/ConfigBuilder.js - About 1 hr to fix

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

      function buildServerOptions(args) {
          var options = {};
          for (var i = 2; i < args.length; i++) {
              if (args[i].indexOf("-") === 0) {
                  var key = args[i];
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function buildFunctionExp has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        var buildFunctionExp = function(exp){
            var paramStart = 0, startIndex = 0;
            var inFunction = false, nestedFunction = false;
            var args = [];
            for(var i=0;i<exp.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 buildMappings has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            buildMappings(mappingFiles, allMappings){
                var fileLevelMappings;
                allMappings = allMappings || [];
                //defaultConfig = config.mappings.default || defaultConfig;
                defaultConfig = deepAssign({},defaultConfig, this.options.mappings.default);
        Severity: Minor
        Found in lib/loaders/MappingsBuilder.js - About 1 hr to fix

          Function redirect has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function redirect(request, response, requestProcessor, baseUrl, options){
              const targetUrl = url.resolve(baseUrl, request.originalUrl);
              const reqOptions = {
                  url: targetUrl,
                  method: request.method,
          Severity: Minor
          Found in lib/server.js - About 1 hr to fix

            Function reload has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                reload(){
                    this.tables = [];
                    if(this.source){
                        try{
                            var files = fs.readdirSync(this.source);
            Severity: Minor
            Found in lib/loaders/DataTablesLoader.js - About 1 hr to fix

              Function requestResponseHandler has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function requestResponseHandler(request, response, requestProcessor) {
                      
                  request.originalUrl = request.url;
                  var parsedURL = url.parse(request.url, true);
                  request.url = parsedURL.pathname;
              Severity: Minor
              Found in lib/server.js - About 1 hr to fix

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

                exports.ls = function(dirpath, ext){
                    if(exports.isExist(dirpath)){
                        const fileList = fs.readdirSync(dirpath);
                        if(ext){
                            const filteredFileList = [];
                Severity: Minor
                Found in lib/util/fileutil.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 build has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    build(options){
                        this.config = {
                            mappings: {},
                            server:{},
                            recordAndPlay : {
                Severity: Minor
                Found in lib/ConfigBuilder.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 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

                Severity
                Category
                Status
                Source
                Language