meteor/meteor

View on GitHub
packages/oauth/oauth_server.js

Summary

Maintainability
C
1 day
Test Coverage

File oauth_server.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import bodyParser from 'body-parser';

OAuth = {};
OAuthTest = {};

Severity: Minor
Found in packages/oauth/oauth_server.js - About 3 hrs to fix

    Function middleware has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    const middleware = async (req, res, next) => {
      let requestData;
    
      // Make sure to catch any exceptions because otherwise we'd crash
      // the runner
    Severity: Minor
    Found in packages/oauth/oauth_server.js - 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 middleware has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const middleware = async (req, res, next) => {
      let requestData;
    
      // Make sure to catch any exceptions because otherwise we'd crash
      // the runner
    Severity: Minor
    Found in packages/oauth/oauth_server.js - About 1 hr to fix

      Function _endOfLoginResponse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      OAuth._endOfLoginResponse = (res, details) => {
        res.writeHead(200, {'Content-Type': 'text/html'});
      
        let redirectUrl;
        if (details.loginStyle === 'redirect') {
      Severity: Minor
      Found in packages/oauth/oauth_server.js - About 1 hr to fix

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

        const renderEndOfLoginResponse = options => {
          // It would be nice to use Blaze here, but it's a little tricky
          // because our mustaches would be inside a <script> tag, and Blaze
          // would treat the <script> tag contents as text (e.g. encode '&' as
          // '&amp;'). So we just do a simple replace.
        Severity: Minor
        Found in packages/oauth/oauth_server.js - About 1 hr to fix

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

          OAuth._renderOauthResults = (res, query, credentialSecret) => {
            // For tests, we support the `only_credential_secret_for_test`
            // parameter, which just returns the credential secret without any
            // surrounding HTML. (The test needs to be able to easily grab the
            // secret and use it to log in.)
          Severity: Minor
          Found in packages/oauth/oauth_server.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 _endOfLoginResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          OAuth._endOfLoginResponse = (res, details) => {
            res.writeHead(200, {'Content-Type': 'text/html'});
          
            let redirectUrl;
            if (details.loginStyle === 'redirect') {
          Severity: Minor
          Found in packages/oauth/oauth_server.js - 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 renderEndOfLoginResponse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          const renderEndOfLoginResponse = options => {
            // It would be nice to use Blaze here, but it's a little tricky
            // because our mustaches would be inside a <script> tag, and Blaze
            // would treat the <script> tag contents as text (e.g. encode '&' as
            // '&amp;'). So we just do a simple replace.
          Severity: Minor
          Found in packages/oauth/oauth_server.js - 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

          There are no issues that match your filters.

          Category
          Status