codenautas/fast-devel-server

View on GitHub

Showing 11 of 13 total issues

Function ordinal has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    ordinal : function (number) {
        return number === 1 ? 'er' : 
               number === 2 ? 'do' :
               number === 3 ? 'ro' :
               number === 4 ? 'to' :
Severity: Minor
Found in server/server.js - About 1 day 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

File server.js has 387 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

// APP

var _ = require('lodash');
Severity: Minor
Found in server/server.js - About 5 hrs to fix

    Function template has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        template: function(locals, done){
            if(locals.directory.match(/\/$/)){
                locals.directory=locals.directory.replace(/\/$/,'');
            }
            var pathParts=locals.directory.split('/');
    Severity: Major
    Found in server/server.js - About 3 hrs to fix

      Function loadFrames has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function loadFrames(){
          var pattern=/^((https?:\/\/)?[-a-z.0-9]+(:\d+)?)\/file(\/|$)/;
          actualFrames.forEach(function(frame){
              frame.controlTagLateral.textContent='T';
              if(!frame.codenautas_info){
      Severity: Major
      Found in server/auto.js - About 2 hrs to fix

        Function onload has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        onload:function(text){
                            if(element.textContent==='...'){
                                element.textContent='';
                            }
                            element.title=text;
        Severity: Major
        Found in server/auto-dir-info.js - About 2 hrs to fix

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

                          onload:function(e){
                              var info=JSON.parse(this.responseText);
                              frame.codenautas_info.originFileName=info.originFileName;
                              if(frame.codenautas_info.mtime!='ignored' && frame.codenautas_info.mtime<info.mtime){
                                  frame.controlTagLateral.textContent='R';
          Severity: Minor
          Found in server/auto.js - About 2 hrs to fix

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

            var serveConvert=function serveConvert(root, opts, adapter){
                if(!adapter){
                    adapter=function(){ return function(x){ return x; }; };
                }
                return function(req,res,next){
            Severity: Minor
            Found in server/server.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if(converter && (req.query.fds || converter.auto || converter.others)){
                          var fileName=root+'/'+req.path;
                          var exts=[ext].concat(converter.others||[]);
                          var p=Promise.resolve({pending:true});
                          var fdsFormat = req.query.fds=='auto' && converter.auto || req.query.fds || converter.auto || 'auto';
              Severity: Critical
              Found in server/server.js - About 1 hr to fix

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

                                        frame.onload=function(){
                                            var insideFrame=false;
                                            try{
                                                insideFrame=pattern.test(frame.contentDocument.URL);
                                            }catch(err){
                Severity: Minor
                Found in server/auto.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                      if(element){
                                                          addDirEntryIcon(element,{
                                                              icon:response.icon,
                                                              value:property,
                                                              property:property
                  Severity: Major
                  Found in server/auto-dir-info.js - About 45 mins to fix

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

                    function ajaxSimple(params){
                        var ajax = new XMLHttpRequest();
                        params.onerror=params.onerror||function(err){ alert(err); };
                        ajax.open(params.method||'get',params.url);
                        ajax.onload=function(e){
                    Severity: Minor
                    Found in server/auto-dir-info.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

                    Severity
                    Category
                    Status
                    Source
                    Language