hugopl/reviewit

View on GitHub

Showing 32 of 32 total issues

Method valid_emoji? has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def valid_emoji?(emoji)
    @emoji ||= %w(+1 -1 100 109 1234 8ball abcd abc ab accept aerial_tramway airplane alarm_clock
                  alien ambulance anchor angel anger angry ant a apple aquarius aries
                  arrow_backward arrow_double_down arrow_double_up arrow_down arrow_down_small
                  arrow_forward arrow_heading_down arrow_heading_up arrow_left arrow_lower_left
Severity: Major
Found in app/helpers/application_helper.rb - About 4 hrs to fix

    Class MergeRequest has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class MergeRequest < ApplicationRecord
      belongs_to :author, class_name: 'User'
      belongs_to :reviewer, class_name: 'User'
      belongs_to :project
    
    
    Severity: Minor
    Found in app/models/merge_request.rb - About 3 hrs to fix

      Function exports has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(api) {
        var validEnv = ['development', 'test', 'production']
        var currentEnv = api.env()
        var isDevelopmentEnv = api.env('development')
        var isProductionEnv = api.env('production')
      Severity: Major
      Found in babel.config.js - About 2 hrs to fix

        Method start_reading_interdiff_file_metadata has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def start_reading_interdiff_file_metadata(line)
            new_file_line = line =~ /^(diff -u|---|\+\+\+)/
            interdiff_tag = line =~ /^(reverted|unchanged|only in patch2|only in patch1)/
            return false if !new_file_line && !interdiff_tag
        
        
        Severity: Minor
        Found in app/models/diff.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 path_diff has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def path_diff(from, to)
              old_parts = from.split('/')
              new_parts = to.split('/')
              output = []
              old_changed = []
        Severity: Minor
        Found in app/models/diff.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

        File diff.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class Diff
          # Source can be :git or :interdiff
          def initialize(diff, source: :git)
            @raw = diff
            @files = {}
        Severity: Minor
        Found in app/models/diff.rb - About 2 hrs to fix

          Method change has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def change
              create_table(:users) do |t|
                ## Database authenticatable
                t.string :name,               null: false
                t.string :email,              null: false, default: ''
          Severity: Major
          Found in db/migrate/20141003232638_create_tables.rb - About 2 hrs to fix

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

              def self.decode(data)
                data = data.bytes if data.is_a?(String)
                it = data.each
                len = it.peek
                #      A..Z
            Severity: Minor
            Found in app/models/base85.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 projects_mr_chart_data has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def projects_mr_chart_data(project)
                period = 20
                first_day = period.days.ago
                mrs = project.merge_requests.group('DATE(created_at)').where('created_at > ?', first_day).count
            
            
            Severity: Minor
            Found in app/helpers/projects_helper.rb - About 1 hr to fix

              Method add_comments has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def add_comments(author, patch, comments, blockers)
                  return if comments.nil?
              
                  blockers ||= {}
              
              
              Severity: Minor
              Found in app/models/merge_request.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 projects_merge_request_chart has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def projects_merge_request_chart(project, role, title)
                  query = project.merge_requests.joins(role).accepted.limit(100)
                                 .select('users.name')
                                 .order('merge_requests.created_at DESC').to_sql
                  db = ActiveRecord::Base.connection
              Severity: Minor
              Found in app/helpers/projects_helper.rb - About 1 hr to fix

                Function show_comment_box has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function show_comment_box(event) {
                    var tr = $(event.target).parents('tr')[0];
                    event.preventDefault();
                
                    if ($(tr).next().hasClass('comments')) {
                Severity: Minor
                Found in app/webpacker/src/javascript/merge_requests.js - About 1 hr to fix

                  Method path_diff has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def path_diff(from, to)
                        old_parts = from.split('/')
                        new_parts = to.split('/')
                        output = []
                        old_changed = []
                  Severity: Minor
                  Found in app/models/diff.rb - About 1 hr to fix

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

                        def run
                          return show_help if ARGV == ['--help']
                          return show_version if ARGV == ['--version']
                    
                          # Due to a bad decision in the past this entire gem modifies the ARGV
                    Severity: Minor
                    Found in lib/reviewit/lib/reviewit/app.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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def update
                        @patch = merge_request.patches.find_by(id: params[:patch_id]) or raise 'Invalid patch'
                        @mr.solve_issues_by_location(current_user, @patch, params[:solved].keys) if params[:solved].present?
                        @mr.add_comments(current_user, @patch, params[:comments], params[:blockers])
                    
                    
                    Severity: Minor
                    Found in app/controllers/merge_requests_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 run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def run
                          check_dirty_working_copy!
                    
                          patches = options[:mr].map { |mr| api.merge_request(mr) }
                    
                    
                    Severity: Minor
                    Found in lib/reviewit/lib/reviewit/action/apply.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

                    Function handle_history_radios has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function handle_history_radios(radio) {
                        var name = radio.name;
                        var value = radio.value;
                    
                        var disableTo = null;
                    Severity: Minor
                    Found in app/webpacker/src/javascript/merge_requests.js - 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 decode has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.decode(data)
                        data = data.bytes if data.is_a?(String)
                        it = data.each
                        len = it.peek
                        #      A..Z
                    Severity: Minor
                    Found in app/models/base85.rb - About 1 hr to fix

                      Function show_comment_box has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function show_comment_box(event) {
                          var tr = $(event.target).parents('tr')[0];
                          event.preventDefault();
                      
                          if ($(tr).next().hasClass('comments')) {
                      Severity: Minor
                      Found in app/webpacker/src/javascript/merge_requests.js - 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 each_change has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def each_change
                            old_ln = old_ln_cache = 0
                            new_ln = new_ln_cache = 0
                      
                            @changes.each_with_index do |line, i|
                      Severity: Minor
                      Found in app/models/diff.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language