dougmoscrop/serverless-http

View on GitHub

Showing 20 of 26 total issues

Function getFramework has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function getFramework(app) {
  if (app instanceof http.Server) {
    return request => {
      const response = new Response(request);
      app.emit('request', request, response)
Severity: Minor
Found in lib/framework/get-framework.js - About 2 hrs to fix

    Function constructor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor({ method }) {
        super({ method });
    
        this[BODY] = [];
        this[HEADERS] = {};
    Severity: Minor
    Found in lib/response.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 14 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = (event, response, options) => {
      const eventType = getEventType(event);
      const { statusCode } = response;
      const { headers, multiValueHeaders } = sanitizeHeaders(Response.headers(response));
    
    
    Severity: Minor
    Found in lib/provider/aws/format-response.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 finish has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = async function finish(item, transform, ...details) {
      await new Promise((resolve, reject) => {
        if (item.finished || item.complete) {
          resolve();
          return;
    Severity: Minor
    Found in lib/finish.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 constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor({ method }) {
        super({ method });
    
        this[BODY] = [];
        this[HEADERS] = {};
    Severity: Minor
    Found in lib/response.js - About 1 hr to fix

      Function getFramework has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function getFramework(app) {
        if (app instanceof http.Server) {
          return request => {
            const response = new Response(request);
            app.emit('request', request, response)
      Severity: Minor
      Found in lib/framework/get-framework.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 = (event, response, options) => {
        const eventType = getEventType(event);
        const { statusCode } = response;
        const { headers, multiValueHeaders } = sanitizeHeaders(Response.headers(response));
      
      
      Severity: Minor
      Found in lib/provider/aws/format-response.js - About 1 hr to fix

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

        module.exports = async function finish(item, transform, ...details) {
          await new Promise((resolve, reject) => {
            if (item.finished || item.complete) {
              resolve();
              return;
        Severity: Minor
        Found in lib/finish.js - About 1 hr to fix

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

          module.exports = function sanitizeHeaders(headers) {
            return Object.keys(headers).reduce((memo, key) => {
                const value = headers[key];
          
                if (Array.isArray(value)) {
          Severity: Minor
          Found in lib/provider/azure/sanitize-headers.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 constructor has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor({ method, url, headers, body, remoteAddress }) {
              super({
                encrypted: true,
                readable: false,
                remoteAddress,
          Severity: Minor
          Found in lib/request.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

              if (event.version === '2.0') {
                event.requestContext.authorizer = event.requestContext.authorizer || {};
                event.requestContext.http.method = event.requestContext.http.method || 'GET';
                event.rawPath = removeBasePath(event.requestPath || event.rawPath, options.basePath);
              } else {
            Severity: Major
            Found in lib/provider/aws/clean-up-event.js - About 1 hr to fix

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

              function recursiveURLDecode(value) {
              
                if (isString(value)) {
                  return specialDecodeURIComponent(value);
                } else if (Array.isArray(value)) {
              Severity: Minor
              Found in lib/provider/aws/clean-up-event.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 sanitizeHeaders has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function sanitizeHeaders(headers) {
                return Object.keys(headers).reduce((memo, key) => {
                    const value = headers[key];
              
                  if (Array.isArray(value)) {
              Severity: Minor
              Found in lib/provider/aws/sanitize-headers.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 cleanupEvent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function cleanupEvent(evt, options) {
                const event = evt || {};
              
                event.requestContext = event.requestContext || {};
                event.body = event.body || '';
              Severity: Minor
              Found in lib/provider/aws/clean-up-event.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

              Avoid too many return statements within this function.
              Open

                  return common(app._core._dispatch({
                    app
                  }));
              Severity: Major
              Found in lib/framework/get-framework.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return common(app.main);
                Severity: Major
                Found in lib/framework/get-framework.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return common((req, res) => {
                        const { url, method, headers, body } = req;
                        app.router.route({ url, method, headers, body }, res);
                      });
                  Severity: Major
                  Found in lib/framework/get-framework.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return common((request, response) => {
                          app._onRequest(request, response);
                        });
                    Severity: Major
                    Found in lib/framework/get-framework.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return common(app);
                      Severity: Major
                      Found in lib/framework/get-framework.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return async request => {
                              const { method, url, headers, body } = request;
                        
                              const res = await app.inject({ method, url, headers, payload: body })
                        
                        
                        Severity: Major
                        Found in lib/framework/get-framework.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language