khalyomede/gridsome-plugin-htaccess

View on GitHub

Showing 26 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private _checkContentSecurityPolicyOption(): void {
            const optionName = "contentSecurityPolicy";
    
            this._throwIfMissingOption(optionName);
            this._throwIfOptionNotObject(optionName);
    Severity: Major
    Found in src/gridsome.server.ts and 1 other location - About 6 hrs to fix
    src/gridsome.server.ts on lines 624..643

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 165.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        private _checkFeaturePolicyOption(): void {
            const optionName = "featurePolicy";
    
            this._throwIfMissingOption(optionName);
            this._throwIfOptionNotObject(optionName);
    Severity: Major
    Found in src/gridsome.server.ts and 1 other location - About 6 hrs to fix
    src/gridsome.server.ts on lines 525..544

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 165.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          private _insertTextCompression(): void {
              if (this._options.textCompression.length > 0) {
                  this._htaccessLines.push("# Enable text compression");
                  this._htaccessLines.push("<IfModule mod_deflate.c>");
      
      
      Severity: Major
      Found in src/gridsome.server.ts and 1 other location - About 5 hrs to fix
      src/gridsome.server.ts on lines 307..319

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 140.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          private _insertBlockedIp(): void {
              if (this._options.blockedIp.length > 0) {
                  this._htaccessLines.push("# Block IP addresses");
                  this._htaccessLines.push("order allow,deny");
      
      
      Severity: Major
      Found in src/gridsome.server.ts and 1 other location - About 5 hrs to fix
      src/gridsome.server.ts on lines 165..179

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 140.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          private _insertDisableDirectoryIndex(): void {
              if (this._options.disableDirectoryIndex) {
                  this._htaccessLines.push("# Disable directory index");
                  this._htaccessLines.push("Options All -Indexes");
                  this._htaccessLines.push("\n");
      Severity: Major
      Found in src/gridsome.server.ts and 1 other location - About 1 hr to fix
      src/gridsome.server.ts on lines 124..132

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          private _insertDisableServerSignature(): void {
              if (this._options.disableServerSignature) {
                  this._htaccessLines.push(
                      "# Prevent your server from sending the version of the server"
                  );
      Severity: Major
      Found in src/gridsome.server.ts and 1 other location - About 1 hr to fix
      src/gridsome.server.ts on lines 116..122

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

                      Severity
                      Category
                      Status
                      Source
                      Language