errbit/errbit

View on GitHub

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

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

            Method filtered has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.filtered(filter)
                if filter
                  filter_components = filter.scan(/(-app):(['"][^'"]+['"]|[^ ]+)/)
                  app_names_to_exclude = filter_components.map do |filter_component_tuple|
                    filter_type, filter_value = filter_component_tuple
            Severity: Minor
            Found in app/models/problem.rb - About 35 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 copy_attributes_from has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def copy_attributes_from(app_id)
                copy_app = App.where(_id: app_id).first
                return if copy_app.blank?
            
                # Copy fields
            Severity: Minor
            Found in app/models/app.rb - About 35 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 uncache_notice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def uncache_notice(notice)
                last_notice = notices.last
            
                atomically do |doc|
                  doc.set(
            Severity: Minor
            Found in app/models/problem.rb - About 35 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

            Severity
            Category
            Status
            Source
            Language