firebase/superstatic

View on GitHub

Showing 26 of 26 total issues

Function exports has 124 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function () {
  return function (req, res, next) {
    const config = req.superstatic;
    const trailingSlashBehavior = config.trailingSlash;

Severity: Major
Found in src/middleware/files.js - About 4 hrs to fix

    Function test has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    Redirect.prototype.test = function (url) {
      let qs = "";
      if (url.indexOf("?") >= 0) {
        const parts = url.split("?");
        url = parts[0];
    Severity: Minor
    Found in src/middleware/redirects.js - About 3 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 provider has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function provider(options: any) {
      const etagCache: Record<string, { timestamp: Date; value: string }> = {};
      const cwd = options.cwd || process.cwd();
      let publicPaths: string[] = options.public || ["."];
      if (!Array.isArray(publicPaths)) {
    Severity: Major
    Found in src/providers/fs.ts - About 2 hrs to fix

      Function test has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Redirect.prototype.test = function (url) {
        let qs = "";
        if (url.indexOf("?") >= 0) {
          const parts = url.split("?");
          url = parts[0];
      Severity: Minor
      Found in src/middleware/redirects.js - About 1 hr to fix

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

        const superstatic = function (spec = {}) {
          if (!spec.stack) {
            spec.stack = "default";
          }
        
        
        Severity: Minor
        Found in src/superstatic.js - About 1 hr to fix

          Function exports has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function () {
            return function (req, res, next) {
              const config = _.get(req, "superstatic.redirects");
              if (!config) {
                return next();
          Severity: Minor
          Found in src/middleware/redirects.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 exports has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function (filename) {
            if (_.isFunction(filename)) {
              return filename;
            }
          
          
          Severity: Minor
          Found in src/loaders/config-file.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 exports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function () {
            return function (req, res, next) {
              const config = _.get(req, "superstatic.redirects");
              if (!config) {
                return next();
          Severity: Minor
          Found in src/middleware/redirects.js - About 1 hr to fix

            Function handleFileStream has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Responder.prototype.handleFileStream = function (file, result) {
              const self = this;
            
              this.streamedFile = file;
              this.res.statusCode = file.status || 200;
            Severity: Minor
            Found in src/responder.js - About 1 hr to fix

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

              module.exports = function (spec) {
                let defaultErrorContent = undefined;
                if (spec.errorPage) {
                  defaultErrorContent = fs.readFileSync(spec.errorPage, "utf8");
                }
              Severity: Minor
              Found in src/middleware/missing.js - About 1 hr to fix

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

                module.exports = function (filename) {
                  if (_.isFunction(filename)) {
                    return filename;
                  }
                
                
                Severity: Minor
                Found in src/loaders/config-file.js - About 1 hr to fix

                  Function superstatic has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const superstatic = function (spec = {}) {
                    if (!spec.stack) {
                      spec.stack = "default";
                    }
                  
                  
                  Severity: Minor
                  Found in src/superstatic.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 getI18nLanguages has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function getI18nLanguages(headers: Record<string, string>): string[] {
                    const overrideValue = cookieValue(
                      headers.cookie,
                      "firebase-language-override",
                    );
                  Severity: Minor
                  Found in src/utils/i18n.ts - About 1 hr to fix

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

                    function getI18nLanguages(headers: Record<string, string>): string[] {
                      const overrideValue = cookieValue(
                        headers.cookie,
                        "firebase-language-override",
                      );
                    Severity: Minor
                    Found in src/utils/i18n.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 handleFileStream has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Responder.prototype.handleFileStream = function (file, result) {
                      const self = this;
                    
                      this.streamedFile = file;
                      this.res.statusCode = file.status || 200;
                    Severity: Minor
                    Found in src/responder.js - 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 _handle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Responder.prototype._handle = function (item) {
                      if (_.isArray(item)) {
                        return this.handleStack(item);
                      } else if (_.isString(item)) {
                        return this.handleFile({ file: item });
                    Severity: Minor
                    Found in src/responder.js - 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 normalizedConfigHeaders has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const normalizedConfigHeaders = function (spec, config) {
                      const out = config || [];
                      if (_.isArray(config)) {
                        const _isAllowed = function (headerToSet) {
                          return _.includes(spec.allowedHeaders, headerToSet.key.toLowerCase());
                    Severity: Minor
                    Found in src/middleware/headers.js - About 45 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 cookieValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function cookieValue(cookieString: string, key: string): string {
                      if (!cookieString) {
                        return "";
                      }
                      const cookies = cookieString.split(";").map((c) => c.trim());
                    Severity: Minor
                    Found in src/utils/i18n.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

                    Avoid too many return statements within this function.
                    Open

                        return this.handleMiddleware(item);
                    Severity: Major
                    Found in src/responder.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return this.handleRewrite(item);
                      Severity: Major
                      Found in src/responder.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language