patrickarlt/acetate

View on GitHub

Showing 27 of 27 total issues

File Acetate.js has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const EventEmitter = require("events").EventEmitter;
const chokidar = require("chokidar");
const path = require("path");
const fs = require("fs");
const _ = require("lodash");
Severity: Major
Found in lib/Acetate.js - About 1 day to fix

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

    function createServer(acetate, options = {}) {
      function notFoundMiddleware(request, response) {
        acetate.log.warn(`404 not found ${url.parse(request.url).pathname}`);
        response.writeHead(404, { "Content-Type": "text/html" });
        response.end(notFoundPageTemplate);
    Severity: Major
    Found in lib/modes/server.js - About 6 hrs to fix

      Acetate has 41 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Acetate extends EventEmitter {
        constructor({
          config = "acetate.config.js",
          sourceDir = "src",
          outDir = "build",
      Severity: Minor
      Found in lib/Acetate.js - About 5 hrs to fix

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

          reloadConfig() {
            this.emit("config:reloading");
            this.reset();
        
            this.require("./helpers/highlight-block.js");
        Severity: Major
        Found in lib/Acetate.js - About 3 hrs to fix

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

          module.exports = function(acetate) {
            acetate.helper(
              "link",
              function(context, destinationUrl, text) {
                const currentUrl = context.options.currentUrl || context.page.url;
          Severity: Minor
          Found in lib/helpers/link-helper.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 exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function(acetate) {
            acetate.helper(
              "link",
              function(context, destinationUrl, text) {
                const currentUrl = context.options.currentUrl || context.page.url;
          Severity: Major
          Found in lib/helpers/link-helper.js - About 2 hrs to fix

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

            module.exports = function(acetate) {
              const pagesCache = {};
            
              const acetateMiddleware = function acetateMiddleware(
                request,
            Severity: Major
            Found in lib/modes/middleware.js - About 2 hrs to fix

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

                  if (args[args.length - 1] && args[args.length - 1].__keywords) {
                    keywords = args.pop();
                    delete keywords.__keywords;
                  } else {
                    keywords = {};
              Severity: Major
              Found in lib/custom-tags/Helper.js and 1 other location - About 1 hr to fix
              lib/custom-tags/Block.js on lines 38..43

              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

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

                  if (args[args.length - 1] && args[args.length - 1].__keywords) {
                    keywords = args.pop();
                    delete keywords.__keywords;
                  } else {
                    keywords = {};
              Severity: Major
              Found in lib/custom-tags/Block.js and 1 other location - About 1 hr to fix
              lib/custom-tags/Helper.js on lines 37..42

              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 acetateMiddleware has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const acetateMiddleware = function acetateMiddleware(
                  request,
                  response,
                  next
                ) {
              Severity: Minor
              Found in lib/modes/middleware.js - About 1 hr to fix

                Function createServer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                function createServer(acetate, options = {}) {
                  function notFoundMiddleware(request, response) {
                    acetate.log.warn(`404 not found ${url.parse(request.url).pathname}`);
                    response.writeHead(404, { "Content-Type": "text/html" });
                    response.end(notFoundPageTemplate);
                Severity: Minor
                Found in lib/modes/server.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 createWatcher has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function createWatcher(acetate) {
                  function removePage(page) {
                    const outputPath = path.join(acetate.outDir, page.dest);
                    deleteFile(outputPath)
                      .then(function() {
                Severity: Minor
                Found in lib/modes/watcher.js - About 1 hr to fix

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

                    _createLoaderTask(
                      pattern,
                      { ignore = [], metadata = {}, basePath = "" } = {}
                    ) {
                      return (createPage, callback) => {
                  Severity: Minor
                  Found in lib/Acetate.js - About 1 hr to fix

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

                      reset() {
                        this._paths = [];
                        this._pages = [];
                        this._pagesLoaded = false;
                        this._loaders = [];
                    Severity: Minor
                    Found in lib/Acetate.js - About 1 hr to fix

                      Function _handlePageWatcherEvent has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        _handlePageWatcherEvent(src, eventName, verb) {
                          this.log.info(`${src} ${verb}`);
                          if (path.basename(src)[0] === "_") {
                            this.emit(`watcher:template:${eventName}`, src);
                          } else {
                      Severity: Minor
                      Found in lib/Acetate.js - About 1 hr to fix

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

                        function run() {
                          if (argv.require && argv.require.length) {
                            argv.require.forEach(dep => {
                              require(dep);
                            });
                        Severity: Minor
                        Found in lib/cli.js - About 1 hr to fix

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

                            transform(pattern, transformer, label) {
                              const matcher = new minimatch.Minimatch(pattern);
                              const transformRunner = function(page, done) {
                                if (!matcher.match(page.src)) {
                                  process.nextTick(() => {
                          Severity: Minor
                          Found in lib/Acetate.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 startPageWatcher has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            startPageWatcher() {
                              if (this._pageWatcher) {
                                this.stopWatcher();
                              }
                          
                          
                          Severity: Minor
                          Found in lib/Acetate.js - About 1 hr to fix

                            Function constructor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              constructor(error, page) {
                                error = typeof error === "string" ? new Error(error) : error;
                                let originalMessage = _.trim(_.last(error.message.split("\n")));
                                if (/ \[(Line) \d+, Column \d+\]/.test(error.message)) {
                                  let originalErrorLocation = error.message.match(/.*: \((.*)\)/);
                            Severity: Minor
                            Found in lib/error-types/PageRenderError.js - About 1 hr to fix

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

                                transform(pattern, transformer, label) {
                                  const matcher = new minimatch.Minimatch(pattern);
                                  const transformRunner = function(page, done) {
                                    if (!matcher.match(page.src)) {
                                      process.nextTick(() => {
                              Severity: Minor
                              Found in lib/Acetate.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language