errbit/errbit

View on GitHub

Showing 35 of 35 total issues

Class App has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class App
  include Comparable
  include Mongoid::Document
  include Mongoid::Timestamps

Severity: Minor
Found in app/models/app.rb - About 3 hrs to fix

    Method rekey has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.rekey(node)
          case node
          when Hash
            if node.key?('var') && node.key?('key')
              { normalize_key(node['key']) => rekey(node['var']) }
    Severity: Minor
    Found in lib/hoptoad/v2.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

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

    class Problem
      include Mongoid::Document
      include Mongoid::Timestamps
    
      CACHED_NOTICE_ATTRIBUTES = {
    Severity: Minor
    Found in app/models/problem.rb - About 2 hrs to fix

      File problem.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Problem
        include Mongoid::Document
        include Mongoid::Timestamps
      
        CACHED_NOTICE_ATTRIBUTES = {
      Severity: Minor
      Found in app/models/problem.rb - About 2 hrs to fix

        Method google_oauth2 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def google_oauth2
            google_uid = env['omniauth.auth'].uid
            google_email = env['omniauth.auth'].info.email
            google_user = User.where(google_uid: google_uid).first
            google_site_title = Errbit::Config.google_site_title
        Severity: Minor
        Found in app/controllers/users/omniauth_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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            response.headers['Access-Control-Allow-Origin'] = '*'
            response.headers['Access-Control-Allow-Headers'] = 'origin, content-type, accept'
            return render(status: 200, text: '') if request.method == 'OPTIONS'
        
        
        Severity: Minor
        Found in app/controllers/api/v3/notices_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 google_oauth2 has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def google_oauth2
            google_uid = env['omniauth.auth'].uid
            google_email = env['omniauth.auth'].info.email
            google_user = User.where(google_uid: google_uid).first
            google_site_title = Errbit::Config.google_site_title
        Severity: Minor
        Found in app/controllers/users/omniauth_callbacks_controller.rb - About 1 hr to fix

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

            def save
              errors.add :base, "The issue has no body" unless body
              errors.add :base, "This app has no issue tracker" unless issue_tracker
              return false if errors.present?
          
          
          Severity: Minor
          Found in app/models/issue.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 rekey has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.rekey(node)
                case node
                when Hash
                  if node.key?('var') && node.key?('key')
                    { normalize_key(node['key']) => rekey(node['var']) }
          Severity: Minor
          Found in lib/hoptoad/v2.rb - About 1 hr to fix

            Method close has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def close
                errors.add :base, "This app has no issue tracker" unless issue_tracker
                return false if errors.present?
            
                tracker.errors.each { |k, err| errors.add k, err }
            Severity: Minor
            Found in app/models/issue.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 generate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def generate(api_key, notice, backtrace)
                material = [api_key]
                material << notice.error_class if error_class
                material << notice.filtered_message if message
                material << notice.component if component
            Severity: Minor
            Found in app/models/notice_fingerprinter.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

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

              def github
                github_login = env["omniauth.auth"].extra.raw_info.login
                github_token = env["omniauth.auth"].credentials.token
                github_site_title = Errbit::Config.github_site_title
                github_user = User.where(github_login: github_login).first || github_auto_sign_up(github_token)
            Severity: Minor
            Found in app/controllers/users/omniauth_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

                input.siblings('.icon').each(function(){ $(this).attr('src', $(this).data('iconCreate')) });
            Severity: Minor
            Found in app/assets/javascripts/form.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/form.js on lines 94..94

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

            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

                wrapper.find('.icon').each(function(){ $(this).attr('src', $(this).data('iconInactive')) });
            Severity: Minor
            Found in app/assets/javascripts/form.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/form.js on lines 95..95

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

            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

            Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                # params[:data] if the notice came from a GET request, raw_post if it came via POST
                report = ErrorReport.new(notice_params)
            
                if report.valid?
            Severity: Minor
            Found in app/controllers/notices_controller.rb - About 45 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

            Method pretty_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def pretty_hash(hash, nesting = 0)
                return '{}' if hash.empty?
            
                tab_size = 2
                nesting += 1
            Severity: Minor
            Found in app/helpers/hash_helper.rb - About 45 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

            Method create_notification has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def create_notification(problem)
                  # @mentions can only be used when format == "text".  See hipchat
                  # api for more info: https://www.hipchat.com/docs/apiv2/method/send_room_notification
                  format = self[:mentions].present? ? "text" : "html"
                  message = (format == "text") ? message_text(problem) : message_html(problem)
            Severity: Minor
            Found in app/models/notification_services/hipchat_service.rb - About 45 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

            Method scan has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def scan
                @mapping.each do |key, values|
                  @overrides[key] = values.pop if values.last.is_a? Proc
                  env_name = values.find { |v| ENV[v] }
                  @storage[key] = if env_name
            Severity: Minor
            Found in lib/configurator.rb - About 45 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

            Method create_notification has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create_notification(problem)
                # build the xmpp client
                client = nil
                Timeout.timeout(5) do
                  client = Jabber::Client.new(Jabber::JID.new(subdomain))
            Severity: Minor
            Found in app/models/notification_services/gtalk_service.rb - About 45 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

                  } else {
                    $('#user_password').parent().attr('class', '')
                    $('#user_password_confirmation').parent().attr('class', '')
                  }
            Severity: Minor
            Found in app/assets/javascripts/errbit.js and 1 other location - About 40 mins to fix
            app/assets/javascripts/errbit.js on lines 99..102

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

            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

            Severity
            Category
            Status
            Source
            Language