QutBioacousticsResearchGroup/bioacoustic-workbench

View on GitHub
app/controllers/api/callbacks_controller.rb

Summary

Maintainability
D
3 days
Test Coverage

File callbacks_controller.rb has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Api::CallbacksController < Devise::OmniauthCallbacksController
  # this may be needed, but haven't needed it yet.
  #skip_before_filter :verify_authenticity_token, :only => [:open_id]

  # NOTES
Severity: Minor
Found in app/controllers/api/callbacks_controller.rb - About 3 hrs to fix

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

      def create_or_update_user(canonical_data, user=nil)
        authorization = nil
    
        #uid = canonical_data[:canonical][:uid] # very likely to be present
        #name = canonical_data[:canonical][:name] # might be present
    Severity: Minor
    Found in app/controllers/api/callbacks_controller.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

    Class CallbacksController has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Api::CallbacksController < Devise::OmniauthCallbacksController
      # this may be needed, but haven't needed it yet.
      #skip_before_filter :verify_authenticity_token, :only => [:open_id]
    
      # NOTES
    Severity: Minor
    Found in app/controllers/api/callbacks_controller.rb - About 2 hrs to fix

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

        def open_id_info(raw)
      
          open_id_name = raw.info.include?(:name) ? raw.info.name : ''
          open_id_nickname = raw.info.include?(:nickname) ? raw.info.nickname : ''
          open_id_any_name = open_id_nickname.blank? ?
      Severity: Minor
      Found in app/controllers/api/callbacks_controller.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 twitter_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def twitter_info(raw)
      
          twitter_name = raw['info'].include?('name') ? raw['info']['name'] : ''
          twitter_nickname = raw['info'].include?('nickname') ? raw['info']['nickname'] : ''
          twitter_any_name = twitter_name.blank? ? (twitter_nickname.blank? ? '' : twitter_nickname) : twitter_name
      Severity: Minor
      Found in app/controllers/api/callbacks_controller.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 create_or_update_user has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_or_update_user(canonical_data, user=nil)
          authorization = nil
      
          #uid = canonical_data[:canonical][:uid] # very likely to be present
          #name = canonical_data[:canonical][:name] # might be present
      Severity: Minor
      Found in app/controllers/api/callbacks_controller.rb - About 1 hr to fix

        Method facebook_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def facebook_info(raw)
        
            facebook_name = raw.info.include?(:name) ? raw.info.name : ''
            facebook_nickname = raw.info.include?(:nickname) ? raw.info.nickname : ''
            facebook_any_name = facebook_name.blank? ? (facebook_nickname.blank? ? '' : facebook_nickname) : facebook_name
        Severity: Minor
        Found in app/controllers/api/callbacks_controller.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 open_id_info has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def open_id_info(raw)
        
            open_id_name = raw.info.include?(:name) ? raw.info.name : ''
            open_id_nickname = raw.info.include?(:nickname) ? raw.info.nickname : ''
            open_id_any_name = open_id_nickname.blank? ?
        Severity: Minor
        Found in app/controllers/api/callbacks_controller.rb - About 1 hr to fix

          Method browser_id has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def browser_id
              # https://developer.mozilla.org/en-US/docs/Persona/Remote_Verification_API
              # this callback will have an assertion included. The assertion should be POST'ed with the
              # audience to the remote verification API
          
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb - 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

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

              if user.blank? &&
                  canonical_data[:authorization].include?(:name) && !canonical_data[:authorization][:name].blank? &&
                  canonical_data[:authorization].include?(:provider) && !canonical_data[:authorization][:provider].blank?
                authorization = Authorization.where(name: canonical_data[:authorization][:name], provider: canonical_data[:authorization][:provider]).first
                unless authorization.blank?
          Severity: Major
          Found in app/controllers/api/callbacks_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/api/callbacks_controller.rb on lines 353..360

          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 55.

          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

              if user.blank? &&
                  canonical_data[:authorization].include?(:uid) && !canonical_data[:authorization][:uid].blank? &&
                  canonical_data[:authorization].include?(:provider) && !canonical_data[:authorization][:provider].blank?
                authorization = Authorization.where(uid: canonical_data[:authorization][:uid], provider: canonical_data[:authorization][:provider]).first
                unless authorization.blank?
          Severity: Major
          Found in app/controllers/api/callbacks_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/api/callbacks_controller.rb on lines 363..370

          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 55.

          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

              respond_to do |format|
                format.json { render :json => window_data.as_json, :status => :unauthorized }
                format.js { render :json => window_data.as_json, :status => :unauthorized }
                format.xml { render :xml => window_data.to_xml, :status => :unauthorized }
                format.any { render :text => window_content(displayed_data, window_data), :status => :unauthorized }
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 1 other location - About 55 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 69..73

          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 45.

          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

              respond_to do |format|
                format.json { render :json => content.as_json, :status => :ok }
                format.js { render :json => content.as_json, :status => :ok }
                format.xml { render :xml => content.to_xml, :status => :ok }
                format.any { render :text => window_content(displayed_data, content), :status => :ok }
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 1 other location - About 55 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 46..50

          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 45.

          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

              if user.is_fake_email &&
                  canonical_data[:user].include?(:is_fake_email) && !canonical_data[:user][:is_fake_email] &&
                  canonical_data[:user].include?(:email) && !canonical_data[:user][:email].blank?
                user.email = canonical_data[:user][:email]
                user.is_fake_email = false
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 1 other location - About 25 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 373..377

          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 29.

          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

              if user.blank? &&
                  canonical_data[:user].include?(:is_fake_email) && !canonical_data[:user][:is_fake_email] &&
                  canonical_data[:user].include?(:email) && !canonical_data[:user][:email].blank?
                user = User.find_by_email(canonical_data[:user][:email])
              end
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 1 other location - About 25 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 417..422

          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 29.

          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 3 locations. Consider refactoring.
          Open

            def windows_live_info(raw)
              {
                  authorization:
                      {
                          provider: 'github',
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 2 other locations - About 20 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 275..292
          app/controllers/api/callbacks_controller.rb on lines 315..332

          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 27.

          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 3 locations. Consider refactoring.
          Open

            def linked_in_info(raw)
              {
                  authorization:
                      {
                          provider: 'github',
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 2 other locations - About 20 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 275..292
          app/controllers/api/callbacks_controller.rb on lines 295..312

          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 27.

          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 3 locations. Consider refactoring.
          Open

            def github_info(raw)
              {
                  authorization:
                      {
                          provider: 'github',
          Severity: Minor
          Found in app/controllers/api/callbacks_controller.rb and 2 other locations - About 20 mins to fix
          app/controllers/api/callbacks_controller.rb on lines 295..312
          app/controllers/api/callbacks_controller.rb on lines 315..332

          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 27.

          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

          There are no issues that match your filters.

          Category
          Status