Antyfive/teo.js

View on GitHub

Showing 16 of 16 total issues

Function send has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    send() {
        let args = [].slice.call(arguments),
            code = 200, body;

        let extension = _.getExtension(this.pathname);
Severity: Minor
Found in core/teo.client.context.res.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

App has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class App extends Base {
    constructor(config, callback) {
        super(config, callback);

        this._middleware = new Middleware();
Severity: Minor
Found in core/teo.app.js - About 3 hrs to fix

    Function send has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        send() {
            let args = [].slice.call(arguments),
                code = 200, body;
    
            let extension = _.getExtension(this.pathname);
    Severity: Minor
    Found in core/teo.client.context.res.js - About 1 hr to fix

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

          * dispatch() {
              if (!this.pathname.startsWith("/public") && this.route != null && typeof this.route.handler === "function") {
                  if (!_.isGenerator(this.route.handler)) {
                      throw new Error("Route handler should be a generator function!");
                  }
      Severity: Minor
      Found in core/teo.client.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 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(router, moduleName, optionalNamespace) {
          // all routes for the particular module will be wrapped with namespace
          let ns = router.ns(typeof optionalNamespace === "string" ? optionalNamespace : `/${moduleName.toLowerCase()}`);
      
          function middleHandler(method) {
      Severity: Minor
      Found in lib/routerMounter.js - About 1 hr to fix

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

            * createServer(dispatcher) {
                const serverConfig = this.config.get("server");
        
                if (!serverConfig.protocol) {
                    throw new Error("Protocol is not set in the server config");
        Severity: Minor
        Found in core/teo.app.js - About 1 hr to fix

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

              * dispatch() {
                  if (!this.pathname.startsWith("/public") && this.route != null && typeof this.route.handler === "function") {
                      if (!_.isGenerator(this.route.handler)) {
                          throw new Error("Route handler should be a generator function!");
                      }
          Severity: Minor
          Found in core/teo.client.js - About 1 hr to fix

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

                readFileSafely(filePath, callback) {
                    try {
                        filePath = decodeURIComponent(filePath);    // decode url
                    } catch(e) {
                        callback(e);
            Severity: Minor
            Found in lib/fileReader.js - About 1 hr to fix

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

              module.exports = function(_moduleName, indexFileAbsPath, routerFilePath, modelFiles) {  // on module register
              
                  return function moduleMounter(context) {   // run on app init, app's context
                      let wrappedRouter = function noop() {};
              
              
              Severity: Minor
              Found in lib/moduleMounter.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

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

              module.exports = function(handlerAbsPath) {
                  var handler = null;
              
                  // expects app's context as first argument, router instance, model register
                  return function handlerMounter(handlerContext/*, router, addModel*/) {
              Severity: Minor
              Found in lib/handlerMounter.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

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

                  * _lifeCircleAction(name, action) {
                      let actions = ["start", "stop", "restart"];
              
                      if (actions.indexOf(action) === -1) {
                          throw new Error(`Not supported action ${action} was received`);
              Severity: Minor
              Found in core/teo.core.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 isGenerator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              util.isGenerator = function(obj) {
              
                  /**
                   * Check if `obj` is a generator.
                   *
              Severity: Minor
              Found in lib/utils.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 createServer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  * createServer(dispatcher) {
                      const serverConfig = this.config.get("server");
              
                      if (!serverConfig.protocol) {
                          throw new Error("Protocol is not set in the server config");
              Severity: Minor
              Found in core/teo.app.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 processExitHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  static processExitHandler(options, err) {
                      options = options || {};
                      if (options.cleanup) {  // TODO: cleanup
                          logger.info("Cleanup");
                      }
              Severity: Minor
              Found in core/teo.core.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 runSingle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  * runSingle(name, context) {
                      let _extension = this._findLoadedByName(name),
                          extensionConfig = this.getExtensionConfig(name);
                      
                      if (!_.isObject(_extension)) {
              Severity: Minor
              Found in core/teo.app.extensions.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 loadConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  loadConfig() {
                      // set node config dir to app's home dir
                      this.config = configLib.loadConfig(this.initialConfig.confDir);
                      // node-config get function
                      let nodeConfigGetter = this.config.get.bind(this.config);
              Severity: Minor
              Found in core/teo.app.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