AllegiantAir/g4js-firewall

View on GitHub

Showing 3 of 5 total issues

Function Rule has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Rule(pattern, roles, methods) {

  // Regex representation of pattern.
  Object.defineProperty(this, 'pattern', {
    enumerable: true,
Severity: Minor
Found in lib/firewall/rule.js - About 1 hr to fix

    Function check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    Firewall.prototype.check = function(pattern, roles, method) {
    
      if (this.basePath) {
        // If basepath does not match skip checks.
        if (pattern.match(this.basePath)===null) {
    Severity: Minor
    Found in lib/firewall/index.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 Rule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function Rule(pattern, roles, methods) {
    
      // Regex representation of pattern.
      Object.defineProperty(this, 'pattern', {
        enumerable: true,
    Severity: Minor
    Found in lib/firewall/rule.js - 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

    Severity
    Category
    Status
    Source
    Language