yamadapc/js-written-number

View on GitHub

Showing 7 of 7 total issues

Function writtenNumber has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

function writtenNumber(n, options) {
  options = options || {};
  options = util.defaults(options, writtenNumber.defaults);

  if (n < 0) {
Severity: Minor
Found in lib/index.js - About 1 day 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 writtenNumber has 130 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function writtenNumber(n, options) {
  options = options || {};
  options = util.defaults(options, writtenNumber.defaults);

  if (n < 0) {
Severity: Major
Found in lib/index.js - About 5 hrs to fix

    Consider simplifying this complex logical expression.
    Open

        } else if (unit.few && (r > 1 && r < 5 || unit.useFewEnding && r % 10 > 1 && r % 10 < 5
          && (!unit.avoidEndingRules || unit.avoidEndingRules.indexOf(r) < 0))) {
          str = unit.few;
        } else {
          str = unit.plural && (!unit.avoidInNumberPlural || !m)
    Severity: Critical
    Found in lib/index.js - About 2 hrs to fix

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

      module.exports = function (grunt) {
          grunt.initConfig({
              clean: {
                  dist: [
                      'dist'
      Severity: Minor
      Found in Gruntfile.js - About 1 hr to fix

        Function handleSmallerThan100 has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function handleSmallerThan100(n, language, unit, baseCardinals, alternativeBaseCardinals, options) {
        Severity: Minor
        Found in lib/index.js - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

              return handleSmallerThan100(n, language, unit, baseCardinals, alternativeBaseCardinals, options);
          Severity: Major
          Found in lib/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return result;
            Severity: Major
            Found in lib/index.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language