ubenzer/metaltext

View on GitHub

Showing 17 of 17 total issues

Function plugin has 169 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function plugin(opts) {
  opts = normalize(opts);

  return function(files, metalsmith, done) {
    // normalize each collections' backend options
Severity: Major
Found in metalsmith/collections.js - About 6 hrs to fix

    Function getBlockCompilerOnSteroids has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function getBlockCompilerOnSteroids(opts) {
      opts = normalize(opts);
    
      return function blockCompilerOnSteroids(files, file, data) {
        return rhoSteroid(
    Severity: Minor
    Found in metalsmith/rhoRenderHelpers.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

    Function getBlockCompilerOnSteroids has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getBlockCompilerOnSteroids(opts) {
      opts = normalize(opts);
    
      return function blockCompilerOnSteroids(files, file, data) {
        return rhoSteroid(
    Severity: Major
    Found in metalsmith/rhoRenderHelpers.js - About 2 hrs to fix

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

        return function blockCompilerOnSteroids(files, file, data) {
          return rhoSteroid(
            {
              renderImg: function(escapedAlt, src, flags) {
                if (checkOwnUrl(src)) {
      Severity: Major
      Found in metalsmith/rhoRenderHelpers.js - About 2 hrs to fix

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

        function renderInnerImg(alt, src, flags) {
          return "<img mtx-src=\"" + src + "\" alt=\"" + alt + "\" class=\"" + s(_.reduce(flags, function(prev, cur) {
              return prev + " " + cur;
            }, "")).trim().s + "\">";
        }
        Severity: Major
        Found in metalsmith/rhoRenderHelpers.js and 1 other location - About 2 hrs to fix
        metalsmith/rhoRenderHelpers.js on lines 99..103

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

        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

        function renderImg(alt, src, flags) {
          return "<img src=\"" + src + "\" alt=\"" + alt + "\" class=\"" + s(_.reduce(flags, function(prev, cur) {
              return prev + " " + cur;
            }, "")).trim().s + "\">";
        }
        Severity: Major
        Found in metalsmith/rhoRenderHelpers.js and 1 other location - About 2 hrs to fix
        metalsmith/rhoRenderHelpers.js on lines 105..109

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

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

            function registerPostOnCategory(collectionId, categoryName, postData) {
              // check if exists, if not append it to proper tree
              var categoryHierarchy = getCollectionContentHierarchy(categoryName);
              var collection = _.findWhere(collections, {id: collectionId});
        
        
        Severity: Major
        Found in metalsmith/collections.js - About 2 hrs to fix

          Function build has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function build() {
            if (config.args.skipBackend === true) {
              debug("Skipping backend build because it is disabled by parameters.");
              return Promise.resolve();
            }
          Severity: Minor
          Found in app/backend.js - About 1 hr to fix

            Function plugin has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function plugin(options) {
              options = normalize(options);
            
              return function(files, metalsmith, done) {
                var processedCollections = metalsmith.metadata().collections;
            Severity: Minor
            Found in metalsmith/createCollectionJson.js - About 1 hr to fix

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

              function downloadFrontendAssets() {
                if (config.args.skipFrontend === true) {
                  debug("Skipping frontend asset generation due to config.");
                  return Promise.resolve();
                }
              Severity: Minor
              Found in app/frontend.js - About 1 hr to fix

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

                        collectionOrCategory.stats.lastPost = _.reduce(collectionOrCategory.$posts, function(pre, curr) { return (pre === null || pre < curr.date) ? curr.date : pre; }, null);
                Severity: Major
                Found in metalsmith/collections.js and 1 other location - About 1 hr to fix
                metalsmith/collections.js on lines 128..128

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

                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

                        collectionOrCategory.stats.ownLastPost = _.reduce(collectionOrCategory.$ownPosts, function(pre, curr) { return (pre === null || pre < curr.date) ? curr.date : pre; }, null);
                Severity: Major
                Found in metalsmith/collections.js and 1 other location - About 1 hr to fix
                metalsmith/collections.js on lines 131..131

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

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

                    function normalizeUrl(urlWithReference) {
                      var surlWithReference = s(urlWithReference);
                      var atCount = surlWithReference.count("@");
                      if (atCount === 1 || atCount > 2) {
                        throw new Error("Can't parse id identifiers: " + urlWithReference);
                Severity: Minor
                Found in metalsmith/rhoRenderHelpers.js - About 1 hr to fix

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

                  function normalize(options) {
                    var defaults = {
                      src: ["**/*"]
                    };
                    options = _.extend({}, defaults, options);
                  Severity: Minor
                  Found in metalsmith/SKELETON.js and 2 other locations - About 30 mins to fix
                  metalsmith/excerpts.js on lines 33..40
                  metalsmith/removeFirstTitle.js on lines 29..36

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

                  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

                  function normalize(options) {
                    var defaults = {
                      src: ["**/*.html"]
                    };
                    options = _.extend({}, defaults, options);
                  Severity: Minor
                  Found in metalsmith/excerpts.js and 2 other locations - About 30 mins to fix
                  metalsmith/SKELETON.js on lines 23..30
                  metalsmith/removeFirstTitle.js on lines 29..36

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

                  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

                  function normalize(options) {
                    var defaults = {
                      src: ["**/*.html"]
                    };
                    options = _.extend({}, defaults, options);
                  Severity: Minor
                  Found in metalsmith/removeFirstTitle.js and 2 other locations - About 30 mins to fix
                  metalsmith/SKELETON.js on lines 23..30
                  metalsmith/excerpts.js on lines 33..40

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

                  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 getConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function getConfig() {
                    if (cachedConfig === null) {
                      var customConfig = {};
                      var defaultConfig = require("../conf/default.js");
                  
                  
                  Severity: Minor
                  Found in app/program.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