brianfunk/capstring

View on GitHub

Showing 15 of 49 total issues

Function cap has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

var cap = function(str,c) {

    var nstr = '';
    
    if (c === 'same') {        
Severity: Minor
Found in index.js - About 4 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 cap has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var cap = function(str,c) {

    var nstr = '';
    
    if (c === 'same') {        
Severity: Major
Found in index.js - About 2 hrs to fix

    Avoid too many return statements within this function.
    Open

            return str.toLowerCase().replace(/i/g, '1').replace(/e/g, '3').replace(/o/g, '0').replace(/l/g, '£').replace(/f/g, 'ƒ').replace(/s/g, '$').replace(/n/g, 'И');
    Severity: Major
    Found in index.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
      Severity: Major
      Found in index.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return str;
        Severity: Major
        Found in index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return str.toUpperCase();
          Severity: Major
          Found in index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return nstr;
            Severity: Major
            Found in index.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return str.toUpperCase().replace(/ /g, '_');
              Severity: Major
              Found in index.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return str.toLowerCase();
                Severity: Major
                Found in index.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return str.replace(/ /g, '_');
                  Severity: Major
                  Found in index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return str.charAt(0).toLowerCase() + cap(str, 'pascal').substr(1);
                    Severity: Major
                    Found in index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return str.split('').reverse().join('');
                      Severity: Major
                      Found in index.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return cap(str, 'title').replace(/ /g, '');
                        Severity: Major
                        Found in index.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return nstr;
                          Severity: Major
                          Found in index.js - About 30 mins to fix

                            Function string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            var string = function(s, opt) {
                                
                                if (!s) {
                                    console.log('s false : ' + s);
                                    return false;
                            Severity: Minor
                            Found in index.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