clay/handlebars

View on GitHub

Showing 20 of 113 total issues

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

module.exports = function (datetime) {
  var date = parse(datetime),
    now = new Date(),
    yesterday = subDays(new Date(), 1),
    // we want an abbreviated version of 'minute' and 'minutes'
Severity: Minor
Found in helpers/time/dateMinimal.js - About 1 hr to fix

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

    module.exports = function (datetime) {
      var date = parse(datetime),
        now = new Date(),
        yesterday = subDays(new Date(), 1),
        // we want an abbreviated version of 'minute' and 'minutes'
    Severity: Minor
    Found in helpers/time/articleDate.js - About 1 hr to fix

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

      module.exports = function (datetime) {
        var date = parse(datetime),
          now = new Date(),
          yesterday = subDays(new Date(), 1),
          // we want an abbreviated version of 'minute' and 'minutes'
      Severity: Minor
      Found in helpers/time/dateMinimal.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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function (datetime) {
        var date = parse(datetime),
          now = new Date(),
          yesterday = subDays(new Date(), 1),
          // we want an abbreviated version of 'minute' and 'minutes'
      Severity: Minor
      Found in helpers/time/articleDate.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 generateDoc has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function generateDoc(helper) {
        const rawDoc = _.find(doc.buildSync([helper], { shallow: true }), function (section) {
          // grab the jsdoc for the exported function
          // note: you must do `module.exports = function () {}`,
          // rather than declaring a named function above and referencing it
      Severity: Minor
      Found in docs/generate-readme.js - About 1 hr to fix

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

        module.exports = function (left, operator, right, options) {
          let result;
        
          if (arguments.length < 3) { // options is always passed in
            throw new Error('Handlerbars Helper "compare" needs 2 parameters');
        Severity: Minor
        Found in helpers/conditionals/compare.js - About 55 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 8 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function (url) {
          var matches,
            multiplier = 1;
        
          if (url && url !== '') {
        Severity: Minor
        Found in helpers/misc/extractImgHeight.js - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function (url) {
          var matches,
            multiplier = 1;
        
          if (url && url !== '') {
        Severity: Minor
        Found in helpers/misc/extractImgWidth.js - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function (conditional, value, options) {
          if (options === undefined) {
            // only two arguments! behave like default handlebars if helper
            options = value;
        
        
        Severity: Minor
        Found in helpers/conditionals/if.js - About 45 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 7 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function (str, a, b) {
          if (str && typeof str === 'string') {
            if (!a || typeof a !== 'string') return str;
            if (!b || typeof b !== 'string') b = '';
            return str.split(a).join(b);
        Severity: Minor
        Found in helpers/strings/replace.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

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

        module.exports = function (value, defaultValue) {
          if (_isObject(value) || _isArray(value)) {
            return !_isEmpty(value) ? value : defaultValue;
          } else {
            return !!value ? value : defaultValue;
        Severity: Minor
        Found in helpers/misc/default.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

        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

                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