gpincheiraa/number2words

View on GitHub

Showing 7 of 7 total issues

Function rules has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

function rules(chunk, chunk_index, total_chunks, chunk_block){
  
  var chunk_text = '',
      parsed_chunk = parseInt(chunk, 10),
      tensBase,
Severity: Minor
Found in src/number2words.js - About 6 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 rules has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function rules(chunk, chunk_index, total_chunks, chunk_block){
  
  var chunk_text = '',
      parsed_chunk = parseInt(chunk, 10),
      tensBase,
Severity: Major
Found in src/number2words.js - About 2 hrs to fix

    Function convert has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function convert(number, chunk_index, total_chunks, converted_text, flag){
      //**********      VARIABLES INICIALES  ********************************
      var chunk_regex = /\d{1,3}(?=(\d{3})*$)/g, //http://goo.gl/oxhsya
          text = converted_text || '',
          chunk,
    Severity: Minor
    Found in src/number2words.js - About 1 hr to fix

      Function convert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      function convert(number, chunk_index, total_chunks, converted_text, flag){
        //**********      VARIABLES INICIALES  ********************************
        var chunk_regex = /\d{1,3}(?=(\d{3})*$)/g, //http://goo.gl/oxhsya
            text = converted_text || '',
            chunk,
      Severity: Minor
      Found in src/number2words.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 addPostfix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      function addPostfix(chunk_block, chunk_number, chunk_index, flag){
        var isOdd = chunk_block % 2 !== 0,
            postfix_text = '';
        if(chunk_number > 0 || flag) {
          if(isOdd){
      Severity: Minor
      Found in src/number2words.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

      Avoid deeply nested control flow statements.
      Open

                  if(hundredsTens[0] === '0'){
                    chunk_text += (chunk.slice(-2) === '01' && chunk_block > 0) ? dictionary['apocopados']['1']
                                                                                : dictionary['decenas']['0-29'][hundredsTens.slice(-1)];
                  }
                  else{
      Severity: Major
      Found in src/number2words.js - About 45 mins to fix

        Function convert has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function convert(number, chunk_index, total_chunks, converted_text, flag){
        Severity: Minor
        Found in src/number2words.js - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language