another-guy/problem-solving-ts

View on GitHub

Showing 26 of 26 total issues

Avoid too many return statements within this function.
Open

  else return magicIndex(array, lowIndex, index - 1);

    Avoid too many return statements within this function.
    Open

      return true;
    Severity: Major
    Found in src/practice/0-undirected-graph.ts - About 30 mins to fix

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

      export function pathExists(graph: Graph, source: string, destination: string): boolean {
        const visited = new Set<string>();
        const toVisit = [ source ];
        while (toVisit.length) {
          const currentNode = toVisit.shift();

      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 splitIntoGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export function splitIntoGroups(bitSequence: string): { g: string, c: number }[] {
        const groups: { g: string, c: number }[] = [];
        let index = 0;
        let group = bitSequence[index];
        let groupLen = 1;
      Severity: Minor
      Found in src/coding-game/1-easy/chuck-norris.ts - 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

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

      export function pathExists(source: string, destination: string, graph: IDirectedGraph): boolean {
        const toVisit = [source];
        const visited = new Set<string | undefined>([]);
      
        while (toVisit.length) {
      Severity: Minor
      Found in src/practice/1-1-top-sort.ts - 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

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

      var twoSumBruteForce = function(nums: number[], target: number): number[] {
        for (let left = 0; left < nums.length - 1; left++)
          for (let right = left + 1; right < nums.length; right++)
            if (nums[left] + nums[right] === target)
              return [left, right];
      Severity: Minor
      Found in src/leet-code/1-easy/1-two-sum.ts - 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