clay/handlebars

View on GitHub

Showing 112 of 113 total issues

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

const name = getName(__filename),
  filterName = __filename.split('/').pop().split('.').shift(),
  filter = require('./' + filterName);
Severity: Minor
Found in helpers/components/filterComponents.test.js and 1 other location - About 35 mins to fix
helpers/components/addAnnotatedTextAria.test.js on lines 2..4

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

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

Avoid too many return statements within this function.
Open

    return '';
Severity: Major
Found in helpers/time/articleDate.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return format(date, 'M/D/YYYY');
    Severity: Major
    Found in helpers/time/dateMinimal.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return format(date, 'M/D/YYYY [at] h:mm aa');
      Severity: Major
      Found in helpers/time/articleDate.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return '';
        Severity: Major
        Found in helpers/time/dateMinimal.js - About 30 mins to fix

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

            it('allows deep path setting', function () {
              expect(hbs.compile('{{ set "a.b.c" "abc" }}{{ a.b.c }}')({})).to.equal('abc');
            });
          Severity: Minor
          Found in helpers/misc/set.test.js and 1 other location - About 30 mins to fix
          helpers/misc/set.test.js on lines 18..20

          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 2 locations. Consider refactoring.
          Open

            it('accepts an optional context', function () {
              expect(hbs.compile('{{ set this "id" "xyz" }}{{ id }}')({})).to.equal('xyz');
            });
          Severity: Minor
          Found in helpers/misc/set.test.js and 1 other location - About 30 mins to fix
          helpers/misc/set.test.js on lines 14..16

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

          module.exports = function (dividend, divisor, remainder, options) {
            var result = dividend % divisor;
          
            // if used as a block helper, this will have options.fn and options.inverse
            // if used inline, simply return true/emptystring
          Severity: Minor
          Found in helpers/conditionals/modulo.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 (num) {
            // if no number is supplied, pass through string
            if (num === '' || isNaN(num)) { // will check numbers and (numbers in) strings
              return new String(num); // will convert to a string if it's a different type
            } else if (isFirst(num)) {
          Severity: Minor
          Found in helpers/numbers/addOrdinalSuffix.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 (str, len, options) {
            var suffix = options === undefined || !_isString(options.hash.suffix) ? '…' : options.hash.suffix;
          
            if (str && typeof str === 'string') {
              return str.trim().length > len ? str.trim().slice(0, len).trim() + suffix : str.trim();
          Severity: Minor
          Found in helpers/strings/truncate.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 (x) {
            const currentNumber = parseInt(x, 10); // always specify radix with arbitrary input
          
            if (isNaN(currentNumber)) {
              return x; // fail gracefully
          Severity: Minor
          Found in helpers/numbers/toK.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 parseType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function parseType(obj) {
            if (obj.type === 'NameExpression') {
              // {array}, {string}, {object}, etc
              return obj.name;
            } else if (obj.type === 'AllLiteral') {
          Severity: Minor
          Found in docs/generate-readme.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