librariesio/libraries.io

View on GitHub
app/models/repository_owner/bitbucket.rb

Summary

Maintainability
C
1 day
Test Coverage

Method create_org has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_org(org_hash)
      return if org_hash.nil?
      org_hash = org_hash.to_hash.with_indifferent_access
      org_hash = {
        id: org_hash[:uuid],
Severity: Minor
Found in app/models/repository_owner/bitbucket.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 create_user has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_user(user_hash)
      return if user_hash.nil?
      user_hash = user_hash.to_hash.with_indifferent_access
      user_hash = {
        id: user_hash[:uuid],
Severity: Minor
Found in app/models/repository_owner/bitbucket.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 create_user has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.create_user(user_hash)
      return if user_hash.nil?
      user_hash = user_hash.to_hash.with_indifferent_access
      user_hash = {
        id: user_hash[:uuid],
Severity: Minor
Found in app/models/repository_owner/bitbucket.rb - About 1 hr to fix

    Method create_org has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.create_org(org_hash)
          return if org_hash.nil?
          org_hash = org_hash.to_hash.with_indifferent_access
          org_hash = {
            id: org_hash[:uuid],
    Severity: Minor
    Found in app/models/repository_owner/bitbucket.rb - About 1 hr to fix

      Method fetch_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.fetch_user(id_or_login)
            begin
              api_client.get_request "/2.0/users/#{URI.escape(id_or_login)}"
            rescue BitBucket::Error::NotFound => error
              if error.message.index('is a team account')
      Severity: Minor
      Found in app/models/repository_owner/bitbucket.rb - 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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

            if user_by_id # its fine
              if user_by_id.login.try(:downcase) == user_hash[:login].downcase && user_by_id.user_type == user_hash[:type]
                user = user_by_id
              else
                if user_by_login && !user_by_login.download_user_from_host
      Severity: Major
      Found in app/models/repository_owner/bitbucket.rb and 2 other locations - About 1 hr to fix
      app/models/repository_owner/github.rb on lines 103..120
      app/models/repository_owner/gitlab.rb on lines 102..119

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

      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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

            if org_by_id # its fine
              if org_by_id.login.try(:downcase) == org_hash[:login].downcase
                org = org_by_id
              else
                if org_by_login && !org_by_login.download_org_from_host
      Severity: Major
      Found in app/models/repository_owner/bitbucket.rb and 2 other locations - About 1 hr to fix
      app/models/repository_owner/github.rb on lines 73..89
      app/models/repository_owner/gitlab.rb on lines 144..160

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

      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

            user_hash = {
              id: user_hash[:uuid],
              login: user_hash[:username],
              name: user_hash[:display_name],
              blog: user_hash[:website],
      Severity: Minor
      Found in app/models/repository_owner/bitbucket.rb and 1 other location - About 20 mins to fix
      app/models/repository_owner/bitbucket.rb on lines 115..123

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

      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

            org_hash = {
              id: org_hash[:uuid],
              login: org_hash[:username],
              name: org_hash[:display_name],
              blog: org_hash[:website],
      Severity: Minor
      Found in app/models/repository_owner/bitbucket.rb and 1 other location - About 20 mins to fix
      app/models/repository_owner/bitbucket.rb on lines 74..82

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

      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