JHStoops/ttrpg-tools

View on GitHub

Showing 10 of 30 total issues

Function generateNpc has a Cognitive Complexity of 10 (exceeds 6 allowed). Consider refactoring.
Open

export function generateNpc({
  familyName, givenName, homeTown, languages, npcClass, npcSubclass, occupation, race, randomizeClass, sex,
} = {}) {
  if (![ undefined, 'female', 'male' ].includes(sex)) throw Error('generateNpc(): sex paramter must be either "female", "male", or undefined.')
  const npcSex = [ 'female', 'male' ].includes(sex) ? sex : getRandomElement([ 'female', 'male' ])
Severity: Minor
Found in src/generators/npc.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 coin has a Cognitive Complexity of 10 (exceeds 6 allowed). Consider refactoring.
Open

export function coin(coinFlips = 1, asNumeric = false, withAdvantage = false, withDisadvantage = false) {
  if (typeof coinFlips !== 'number') throw Error('coin(): coinFlips must be a Number.')
  if (coinFlips < 1) throw Error('coin(): coinFlips must be greater or equal to 1.')

  const headsCount = Array(coinFlips).fill(0).reduce((acc) => {
Severity: Minor
Found in src/generators/dice.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 d20 has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

export function d20(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
Severity: Minor
Found in src/generators/dice.js - About 35 mins to fix

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

    export function d100(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
    Severity: Minor
    Found in src/generators/dice.js - About 35 mins to fix

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

      export function d12(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
      Severity: Minor
      Found in src/generators/dice.js - About 35 mins to fix

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

        export function diceRoll(dice, verbose, modifier = 0, withAdvantage = false, withDisadvantage = false) {
        Severity: Minor
        Found in src/generators/dice.js - About 35 mins to fix

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

          export function d10(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
          Severity: Minor
          Found in src/generators/dice.js - About 35 mins to fix

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

            export function d8(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
            Severity: Minor
            Found in src/generators/dice.js - About 35 mins to fix

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

              export function d4(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
              Severity: Minor
              Found in src/generators/dice.js - About 35 mins to fix

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

                export function d6(dieCount = 1, verbose = false, modifier = 0, withAdvantage = false, withDisadvantage = false) {
                Severity: Minor
                Found in src/generators/dice.js - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language