chiiya/haven

View on GitHub

Showing 4 of 135 total issues

Function attachListeners has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public attachListeners(): void {
    const purposes = getAllPurposes();
    const checkboxes: { [purpose: string]: HTMLInputElement } = {};
    const saveButton = <HTMLButtonElement | null>document.getElementById(
      "cookie-preferences__save"
Severity: Minor
Found in src/preferences/index.ts - About 1 hr to fix

    Function init has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public init(): void {
        // Use custom cookie notification if present
        this.cookieNotification = document.getElementById("cookie-notification");
    
        // If no custom cookie notification is found, create a default one.
    Severity: Minor
    Found in src/notification/index.ts - About 1 hr to fix

      Function get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        public static get(key: string): string | undefined {
          const cookies = document.cookie ? document.cookie.split('; ') : [];
          for (const cookie of cookies) {
            const parts = cookie.split('=');
            const name = decode(parts[0]);
      Severity: Minor
      Found in src/cookies/cookies.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

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

        public static resolveBaseConfiguration(options: Partial<HavenOptions>) {
          for (const item of ["prefix", "cookies", "type", "services", "purposes"]) {
            if (options[item] !== undefined) {
              store[item] = options[item];
            }
      Severity: Minor
      Found in src/store/configuration-resolver.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