openjaf/cenit

View on GitHub
app/models/setup/base_oauth_provider.rb

Summary

Maintainability
C
1 day
Test Coverage

Method lazada_rest_api_refresh_token has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def lazada_rest_api_refresh_token(authorization)
      if is_time_to_refresh?(authorization, Cenit.delay_time_for_lazada_token_refresh)
        client = authorization.client
        fail 'Missing client configuration' unless client
        fail 'Missing OAuth provider configuration' unless authorization.provider
Severity: Minor
Found in app/models/setup/base_oauth_provider.rb - 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

Method default_refresh_token has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def default_refresh_token(authorization)
      if (refresh_token = authorization.refresh_token) && is_time_to_refresh?(authorization)
        fail 'Missing client configuration' unless (client = authorization.client)
        http_response = HTTMultiParty.post(
          authorization.token_endpoint,
Severity: Minor
Found in app/models/setup/base_oauth_provider.rb - 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

Method intuit_reconnect_api_v1_refresh_token has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def intuit_reconnect_api_v1_refresh_token(authorization)
      return unless authorization.authorized_at + 151.days < Time.now
      url = 'https://appcenter.intuit.com/api/v1/connection/reconnect'
      response = Setup::Connection.get(url).with(authorization).submit(http_proxy_address: Cenit.http_proxy_address,
                                                                       http_proxy_port: Cenit.http_proxy_port)
Severity: Minor
Found in app/models/setup/base_oauth_provider.rb - 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

Method google_v4_refresh_token has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def google_v4_refresh_token(authorization)
      if (refresh_token = authorization.refresh_token) && is_time_to_refresh?(authorization)
        fail 'Missing client configuration' unless authorization.client
        post = Setup::Connection.post('https://www.googleapis.com/oauth2/v4/token')
        http_response = post.submit(
Severity: Minor
Found in app/models/setup/base_oauth_provider.rb - 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

Method default_refresh_token has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def default_refresh_token(authorization)
      if (refresh_token = authorization.refresh_token) && is_time_to_refresh?(authorization)
        fail 'Missing client configuration' unless (client = authorization.client)
        http_response = HTTMultiParty.post(
          authorization.token_endpoint,
Severity: Minor
Found in app/models/setup/base_oauth_provider.rb - About 1 hr to fix

    Method lazada_rest_api_refresh_token has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def lazada_rest_api_refresh_token(authorization)
          if is_time_to_refresh?(authorization, Cenit.delay_time_for_lazada_token_refresh)
            client = authorization.client
            fail 'Missing client configuration' unless client
            fail 'Missing OAuth provider configuration' unless authorization.provider
    Severity: Minor
    Found in app/models/setup/base_oauth_provider.rb - About 1 hr to fix

      Method google_v4_refresh_token has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def google_v4_refresh_token(authorization)
            if (refresh_token = authorization.refresh_token) && is_time_to_refresh?(authorization)
              fail 'Missing client configuration' unless authorization.client
              post = Setup::Connection.post('https://www.googleapis.com/oauth2/v4/token')
              http_response = post.submit(
      Severity: Minor
      Found in app/models/setup/base_oauth_provider.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status