denis-sokolov/portent

View on GitHub

Showing 18 of 18 total issues

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

module.exports = function(directory, options){
    options = options || {};
    options.minify = Boolean(options.minify);
    options.sourcemaps = Boolean(options.sourcemaps);

Severity: Minor
Found in src/stylesheets.js - About 5 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 128 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(directory, options){
    options = options || {};
    options.minify = Boolean(options.minify);
    options.sourcemaps = Boolean(options.sourcemaps);

Severity: Major
Found in src/stylesheets.js - About 5 hrs to fix

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

    module.exports = function(templates, plugins){
        var render = function(dirs, req, requestPath){
            return renderNunjucks(dirs, requestPath.normalize('NFC'))
                .then(null, function(error){
                    if (error.templateNotFound)
    Severity: Major
    Found in src/pages/render/index.js - About 3 hrs to fix

      Function render has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var render = function(dirs, req, requestPath){
              return renderNunjucks(dirs, requestPath.normalize('NFC'))
                  .then(null, function(error){
                      if (error.templateNotFound)
                          return renderNunjucks(dirs, requestPath.normalize('NFD'));
      Severity: Major
      Found in src/pages/render/index.js - About 2 hrs to fix

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

        module.exports = function(projectDirectory, plugins, options){
            options = options || {};
            options.minify = Boolean(options.minify);
        
            var templates = templatesFactory(projectDirectory);
        Severity: Major
        Found in src/pages/index.js - About 2 hrs to fix

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

          module.exports = function(directory, options){
              options = options || {};
          
              var jsDirectories = [directory + '/js'];
          
          
          Severity: Major
          Found in src/scripts.js - About 2 hrs to fix

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

                                            if ($('body').length)
                                                $('body').append(tag);
                                            else if ($('html').length)
                                                $('html').append(tag);
                                            else $.root().append(tag);
            Severity: Major
            Found in src/pages/render/index.js and 1 other location - About 1 hr to fix
            src/pages/render/index.js on lines 76..80

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

            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

                                            else if ($('html').length)
                                                $('html').prepend(tag);
                                            else if ($('body').length)
                                                $('body').before(tag);
                                            else $.root().prepend(tag);
            Severity: Major
            Found in src/pages/render/index.js and 1 other location - About 1 hr to fix
            src/pages/render/index.js on lines 56..60

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

            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

            Function get has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var get = function(getOpts){
                    getOpts = getOpts || {};
                    var getFilesOptions = {};
                    if (getOpts.ie) {
                        getFilesOptions.include = new RegExp('\\.ie' + getOpts.ie + '\\.[a-z]+$');
            Severity: Minor
            Found in src/stylesheets.js - About 1 hr to fix

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

              module.exports = function(directory){
                  // Ensure the code works with symlinks and ../ in the path
                  directory = fs.realpathSync(directory);
              
                  return {
              Severity: Minor
              Found in src/index.js - About 1 hr to fix

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

                module.exports = function(directory){
                    var pagesDirectory = directory + '/pages';
                    var dirs = [__dirname, pagesDirectory];
                    var errorDirectory = path.join(directory, 'errors');
                
                
                Severity: Minor
                Found in src/pages/templates/index.js - About 1 hr to fix

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

                  module.exports = function(imgpath){
                      return {
                          middleware: function(req, res, next){
                              if (req.path !== '/favicon.png')
                                  return next();
                  Severity: Minor
                  Found in src/favicon.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(directories, extensions, opts){
                      opts = opts || {};
                      if (typeof directories === 'string')
                          directories = [directories];
                      return Promise.all(directories.map(function(directory){
                  Severity: Minor
                  Found in src/util/get-files.js - About 1 hr to fix

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

                    module.exports = function(projectDirectory, plugins, options){
                        options = options || {};
                        options.minify = Boolean(options.minify);
                    
                        var templates = templatesFactory(projectDirectory);
                    Severity: Minor
                    Found in src/pages/index.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 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports = function(imgpath){
                        return {
                            middleware: function(req, res, next){
                                if (req.path !== '/favicon.png')
                                    return next();
                    Severity: Minor
                    Found in src/favicon.js - About 1 hr to fix

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

                      module.exports = function(templates, plugins){
                          var render = function(dirs, req, requestPath){
                              return renderNunjucks(dirs, requestPath.normalize('NFC'))
                                  .then(null, function(error){
                                      if (error.templateNotFound)
                      Severity: Minor
                      Found in src/pages/render/index.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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      module.exports = function(directory, options){
                          options = options || {};
                      
                          var jsDirectories = [directory + '/js'];
                      
                      
                      Severity: Minor
                      Found in src/scripts.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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      module.exports = function(directory){
                          return {
                              middleware: function(req, res, next){
                                  if (req.path !== '/.htaccess')
                                      return next();
                      Severity: Minor
                      Found in src/htaccess/index.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