khalyomede/gridsome-plugin-htaccess

View on GitHub

Showing 18 of 26 total issues

File gridsome.server.ts has 708 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
    InvalidArgumentError,
    InvalidCharacterError,
    MissingKeyError,
} from "./exception";
Severity: Major
Found in src/gridsome.server.ts - About 1 day to fix

    GridsomePluginHtaccess has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class GridsomePluginHtaccess {
        protected _options: IOptions;
        protected _htaccessLines: Array<string>;
        protected _htaccessContent: string;
    
    
    Severity: Minor
    Found in src/gridsome.server.ts - About 6 hrs to fix

      Function _checkFileExpirations has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          private _checkFileExpirations(): void {
              const optionName = "fileExpirations";
      
              this._throwIfMissingOption(optionName);
              this._throwIfOptionNotObject(optionName);
      Severity: Minor
      Found in src/gridsome.server.ts - About 2 hrs 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 _checkRedirectionsOption has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          private _checkRedirectionsOption(): void {
              const optionName = "redirections";
      
              this._throwIfMissingOption(optionName);
              this._throwIfOptionNotArray(optionName);
      Severity: Minor
      Found in src/gridsome.server.ts - 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 _checkRedirectionsOption has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private _checkRedirectionsOption(): void {
              const optionName = "redirections";
      
              this._throwIfMissingOption(optionName);
              this._throwIfOptionNotArray(optionName);
      Severity: Minor
      Found in src/gridsome.server.ts - About 1 hr to fix

        Function _checkFileExpirations has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private _checkFileExpirations(): void {
                const optionName = "fileExpirations";
        
                this._throwIfMissingOption(optionName);
                this._throwIfOptionNotObject(optionName);
        Severity: Minor
        Found in src/gridsome.server.ts - About 1 hr to fix

          Function constructor has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public constructor(api: IApi, options: IOptions) {
                  this._htaccessLines = [];
                  this._options = options;
                  this._htaccessContent = "";
          
          
          Severity: Minor
          Found in src/gridsome.server.ts - About 1 hr to fix

            Function _insertFileExpirations has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private _insertFileExpirations(): void {
                    if (
                        "default" in this._options.fileExpirations &&
                        this._options.fileExpirations.default !== undefined &&
                        this._options.fileExpirations.default.length > 0
            Severity: Minor
            Found in src/gridsome.server.ts - About 1 hr to fix

              Function _insertContentSecurityPolicy has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private _insertContentSecurityPolicy(): void {
                      if (Object.keys(this._options.contentSecurityPolicy).length > 0) {
                          const policies: Array<string> = [];
              
                          for (const policyName in this._options.contentSecurityPolicy) {
              Severity: Minor
              Found in src/gridsome.server.ts - About 1 hr to fix

                Function _checkPreventDdosAttacksOption has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private _checkPreventDdosAttacksOption(): void {
                        if (
                            "preventDdosAttacks" in this._options &&
                            this._options.preventDdosAttacks !== undefined
                        ) {
                Severity: Minor
                Found in src/gridsome.server.ts - About 1 hr to fix

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

                      private _insertNotCachedFiles(): void {
                          if (this._options.notCachedFiles.length > 0) {
                              this._htaccessLines.push(
                                  "# Prevent the following files to be cached by your users' browser"
                              );
                  Severity: Minor
                  Found in src/gridsome.server.ts - About 1 hr to fix

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

                        private _checkCustomContent(): void {
                            const optionName = "customContent";
                    
                            if (
                                optionName in this._options &&
                    Severity: Minor
                    Found in src/gridsome.server.ts - About 1 hr to fix

                      Function _checkCustomContent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _checkCustomContent(): void {
                              const optionName = "customContent";
                      
                              if (
                                  optionName in this._options &&
                      Severity: Minor
                      Found in src/gridsome.server.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 _insertFileExpirations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _insertFileExpirations(): void {
                              if (
                                  "default" in this._options.fileExpirations &&
                                  this._options.fileExpirations.default !== undefined &&
                                  this._options.fileExpirations.default.length > 0
                      Severity: Minor
                      Found in src/gridsome.server.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 _checkPreventDdosAttacksOption has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _checkPreventDdosAttacksOption(): void {
                              if (
                                  "preventDdosAttacks" in this._options &&
                                  this._options.preventDdosAttacks !== undefined
                              ) {
                      Severity: Minor
                      Found in src/gridsome.server.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 _checkContentSecurityPolicyOption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _checkContentSecurityPolicyOption(): void {
                              const optionName = "contentSecurityPolicy";
                      
                              this._throwIfMissingOption(optionName);
                              this._throwIfOptionNotObject(optionName);
                      Severity: Minor
                      Found in src/gridsome.server.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 _throwIfOptionNotObjectOfArraysOfStrings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _throwIfOptionNotObjectOfArraysOfStrings(option: string): void {
                              for (const key in this._options[option]) {
                                  const array = this._options[option][key];
                      
                                  for (const [index, item] of array.entries()) {
                      Severity: Minor
                      Found in src/gridsome.server.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 _checkFeaturePolicyOption has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _checkFeaturePolicyOption(): void {
                              const optionName = "featurePolicy";
                      
                              this._throwIfMissingOption(optionName);
                              this._throwIfOptionNotObject(optionName);
                      Severity: Minor
                      Found in src/gridsome.server.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