manyike/current-month-week-number

View on GitHub

Showing 6 of 8 total issues

Function weekNumberForGivenDate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function weekNumberForGivenDate (fullYear, fullMonth, dateOfTheMonth) {

    if (!fullYear || !fullMonth || !dateOfTheMonth) {
        return undefined;
    }
Severity: Minor
Found in index.js - About 2 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 weekNumberForGivenDate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function weekNumberForGivenDate (fullYear, fullMonth, dateOfTheMonth) {

    if (!fullYear || !fullMonth || !dateOfTheMonth) {
        return undefined;
    }
Severity: Minor
Found in index.js - About 1 hr to fix

    Avoid too many return statements within this function.
    Open

            return 'dateOfTheMonth should be between 1 and 31 i.e >=1 and <=31';
    Severity: Major
    Found in index.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return 'supplied date is not valid';
      Severity: Major
      Found in index.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return thisMonthTracker[dateOfTheMonth.toString()];
        Severity: Major
        Found in index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return 'dateOfTheMonth should be between 1 and 31 i.e >=1 and <=31 and not 01 or 09';
          Severity: Major
          Found in index.js - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language