arrowjs/ArrowjsCore

View on GitHub
libs/global_function.js

Summary

Maintainability
F
1 wk
Test Coverage

Function getRawConfig has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.getRawConfig = function getRawConfig() {
    let conf = {};

    //get config.js
    try {
Severity: Minor
Found in libs/global_function.js - About 7 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 getRawConfig has 128 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.getRawConfig = function getRawConfig() {
    let conf = {};

    //get config.js
    try {
Severity: Major
Found in libs/global_function.js - About 5 hrs to fix

    File global_function.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const _ = require('lodash'),
        glob = require('glob'),
        fs = require('fs'),
    Severity: Minor
    Found in libs/global_function.js - About 3 hrs to fix

      Function getAllFunction has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.getAllFunction = function (env, viewSetting, app) {
          let self = this;
          let basePath = path.resolve(__dirname, '..', 'templateExtends/function');
          let baseFunctionLinks = self.getGlobbedFiles(path.normalize(basePath + "/*.js"));
          baseFunctionLinks.map(function (link) {
      Severity: Minor
      Found in libs/global_function.js - About 2 hrs to fix

        Function getAllCustomFilter has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.getAllCustomFilter = function (env, viewSetting, app) {
            let self = this;
        
            let basePath = path.resolve(__dirname, '..', 'templateExtends/filter');
            let baseFilterLinks = self.getGlobbedFiles(path.normalize(basePath + "/*.js"));
        Severity: Minor
        Found in libs/global_function.js - About 1 hr to fix

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

          module.exports.getGlobbedFiles = function (globPatterns, removeRoot) {
              // For context switching
              let _this = this;
          
              // URL paths regex
          Severity: Minor
          Found in libs/global_function.js - About 1 hr to fix

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

            module.exports.getGlobbedFiles = function (globPatterns, removeRoot) {
                // For context switching
                let _this = this;
            
                // URL paths regex
            Severity: Minor
            Found in libs/global_function.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

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

                baseFilterLinks.map(function (link) {
                    let name = path.basename(link, ".js")
                    let filter = require(link);
                    /* istanbul ignore else */
                    if (typeof filter === 'object' && !_.isEmpty(filter)) {
            Severity: Major
            Found in libs/global_function.js and 1 other location - About 1 day to fix
            libs/global_function.js on lines 183..201

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

            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

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

                filterLinks.map(function (link) {
                    let name = path.basename(link, ".js");
                    let filter = require(link);
                    /* istanbul ignore else */
                    if (typeof filter === 'object' && !_.isEmpty(filter)) {
            Severity: Major
            Found in libs/global_function.js and 1 other location - About 1 day to fix
            libs/global_function.js on lines 162..180

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

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/error.js');
                    _.assign(conf, require(__base + 'config/error'));
                } catch (err) {
            
            
            Severity: Major
            Found in libs/global_function.js and 4 other locations - About 4 hrs to fix
            libs/global_function.js on lines 302..315
            libs/global_function.js on lines 333..344
            libs/global_function.js on lines 347..358
            libs/global_function.js on lines 397..408

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

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/view.js');
                    _.assign(conf, require(__base + 'config/view'));
                } catch (err) {
                    /* istanbul ignore else */
            Severity: Major
            Found in libs/global_function.js and 4 other locations - About 4 hrs to fix
            libs/global_function.js on lines 302..315
            libs/global_function.js on lines 318..330
            libs/global_function.js on lines 333..344
            libs/global_function.js on lines 397..408

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

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/websocket.js');
                    _.assign(conf, require(__base + 'config/websocket'));
                } catch (err) {
            
            
            Severity: Major
            Found in libs/global_function.js and 4 other locations - About 4 hrs to fix
            libs/global_function.js on lines 318..330
            libs/global_function.js on lines 333..344
            libs/global_function.js on lines 347..358
            libs/global_function.js on lines 397..408

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

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/database.js');
                    _.assign(conf, require(__base + 'config/database'));
                } catch (err) {
                    /* istanbul ignore else */
            Severity: Major
            Found in libs/global_function.js and 4 other locations - About 4 hrs to fix
            libs/global_function.js on lines 302..315
            libs/global_function.js on lines 318..330
            libs/global_function.js on lines 333..344
            libs/global_function.js on lines 347..358

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

            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

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/redis.js');
                    _.assign(conf, require(__base + 'config/redis'));
                } catch (err) {
                    /* istanbul ignore else */
            Severity: Major
            Found in libs/global_function.js and 4 other locations - About 4 hrs to fix
            libs/global_function.js on lines 302..315
            libs/global_function.js on lines 318..330
            libs/global_function.js on lines 347..358
            libs/global_function.js on lines 397..408

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

            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/passport.js');
                } catch (err) {
                    /* istanbul ignore else */
                    if (err.code === 'ENOENT') {
            Severity: Major
            Found in libs/global_function.js and 2 other locations - About 2 hrs to fix
            libs/global_function.js on lines 361..370
            libs/global_function.js on lines 373..382

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

            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/express.js');
                } catch (err) {
                    /* istanbul ignore else */
                    if (err.code === 'ENOENT') {
            Severity: Major
            Found in libs/global_function.js and 2 other locations - About 2 hrs to fix
            libs/global_function.js on lines 361..370
            libs/global_function.js on lines 385..394

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

            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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                try {
                    fs.accessSync(__base + 'config/session.js');
                } catch (err) {
                    /* istanbul ignore else */
                    if (err.code === 'ENOENT') {
            Severity: Major
            Found in libs/global_function.js and 2 other locations - About 2 hrs to fix
            libs/global_function.js on lines 373..382
            libs/global_function.js on lines 385..394

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

            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

                                if (func.async) {
                                    env.addGlobal(func.name, function () {
                                        var argsAsArray = Array.prototype.slice.call(arguments);
                                        return func.handler.bind.apply(func.handler, [null].concat(argsAsArray))
                                    })
            Severity: Major
            Found in libs/global_function.js and 1 other location - About 2 hrs to fix
            libs/global_function.js on lines 136..143

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

            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

                                if (func.async) {
                                    env.addGlobal(func.name, function () {
                                        var argsAsArray = Array.prototype.slice.call(arguments);
                                        return func.handler.bind.apply(func.handler, [null].concat(argsAsArray))
                                    })
            Severity: Major
            Found in libs/global_function.js and 1 other location - About 2 hrs to fix
            libs/global_function.js on lines 109..116

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

            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

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

                    Object.keys(userVariable).map(function (name) {
                        if (typeof userVariable[name] !== "function") {
                            env.addGlobal(name, userVariable[name]);
                        }
                    })
            Severity: Major
            Found in libs/global_function.js and 1 other location - About 1 hr to fix
            libs/global_function.js on lines 47..51

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

            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

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

                Object.keys(baseVariable).map(function (name) {
                    if (typeof baseVariable[name] !== "function") {
                        env.addGlobal(name, baseVariable[name]);
                    }
                });
            Severity: Major
            Found in libs/global_function.js and 1 other location - About 1 hr to fix
            libs/global_function.js on lines 54..58

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

            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