juice-shop/juice-shop

View on GitHub
rsn/rsnUtil.ts

Summary

Maintainability
A
3 hrs
Test Coverage

Function checkDiffs has 66 lines of code (exceeds 30 allowed). Consider refactoring.
Open

const checkDiffs = async (keys: string[]) => {
  const data: CacheData = keys.reduce((prev, curr) => {
    return {
      ...prev,
      [curr]: {
Severity: Major
Found in rsn/rsnUtil.ts - About 2 hrs to fix

    Function checkData has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
    Open

    function checkData (data: CacheData, fileData: CacheData) {
      const filesWithDiff = []
      for (const key in data) {
        const fileDataValueAdded = fileData[key].added.sort((a, b) => a - b)
        const dataValueAdded = data[key].added.sort((a, b) => a - b)
    Severity: Minor
    Found in rsn/rsnUtil.ts - 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 seePatch has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
    Open

    async function seePatch (file: string) {
      const fileData = fs.readFileSync(fixesPath + '/' + file).toString()
      const snippet = await retrieveCodeSnippet(file.split('_')[0])
      if (snippet == null) return
      const patch = Diff.structuredPatch(file, file, filterString(snippet.snippet), filterString(fileData))
    Severity: Minor
    Found in rsn/rsnUtil.ts - About 35 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

    There are no issues that match your filters.

    Category
    Status