secureCodeBox/secureCodeBox

View on GitHub
scanners/whatweb/parser/parser.js

Summary

Maintainability
B
4 hrs
Test Coverage
A
100%

Function parseResultFile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function parseResultFile(fileContent) {
    let targetList = [];

    for(const rawTarget of fileContent) {
      if (Object.keys(rawTarget).length > 0) { //Check for empty target
Severity: Minor
Found in scanners/whatweb/parser/parser.js - About 1 hr 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 parseResultFile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function parseResultFile(fileContent) {
    let targetList = [];

    for(const rawTarget of fileContent) {
      if (Object.keys(rawTarget).length > 0) { //Check for empty target
Severity: Minor
Found in scanners/whatweb/parser/parser.js - About 1 hr to fix

    Function transformToFindings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function transformToFindings(targets) {
    
      const targetFindings = targets.map(target => {
        let finding = {
          name: target.uri,
    Severity: Minor
    Found in scanners/whatweb/parser/parser.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                  switch(key) {
                    case "IP": newTarget.ipAddress = value.string[0]; break;
                    case "Title": newTarget.title = value.string[0]; break;
                    case "HTML5": newTarget.html5 = true; break;
                    case "Country": newTarget.country = value.string[0] + "/" + value.module[0]; break;
      Severity: Major
      Found in scanners/whatweb/parser/parser.js - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status