agile-alliance-brazil/submissions

View on GitHub

Showing 52 of 52 total issues

Method execute_grouped_calculation has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def execute_grouped_calculation(operation, column_name, distinct) #:nodoc:
        group_attrs = group_values

        if group_attrs.first.respond_to?(:to_sym)
          association  = @klass._reflect_on_association(group_attrs.first)
Severity: Minor
Found in lib/active_record_extensions/relation/calculations.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 Conference has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class Conference < ApplicationRecord
  include AutoCompleteUsername

  has_attached_file :logo, styles: { medium: '300x80>', thumb: '75x20>' }
  validates_attachment :logo,
Severity: Minor
Found in app/models/conference.rb - About 3 hrs to fix

    Method execute_grouped_calculation has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def execute_grouped_calculation(operation, column_name, distinct) #:nodoc:
            group_attrs = group_values
    
            if group_attrs.first.respond_to?(:to_sym)
              association  = @klass._reflect_on_association(group_attrs.first)
    Severity: Major
    Found in lib/active_record_extensions/relation/calculations.rb - About 2 hrs to fix

      Method update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
          prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
      
          resource_updated = update_resource(resource, account_update_params)
      Severity: Minor
      Found in app/controllers/registrations_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 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          return render nothing: true, status: 503 if Rails.env == 'production'
      
          build_resource(sign_up_params)
      
      
      Severity: Minor
      Found in app/controllers/registrations_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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          self.resource = resource_class.reset_password_by_token(resource_params)
      
          if resource.errors.empty?
            resource.unlock_access! if unlockable?(resource)
      Severity: Minor
      Found in app/controllers/password_resets_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 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          @conference = Conference.new(new_conference_params)
          page = @conference.pages.build(path: 'home')
          track = @conference.tracks.build
          audience_level = @conference.audience_levels.build
      Severity: Minor
      Found in app/controllers/conferences_controller.rb - About 1 hr to fix

        Method privileges has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def privileges
              can(:manage, ::Reviewer, conference: { visible: true })
              can(:read, 'organizer_sessions') do
                @conference.visible?
              end
        Severity: Minor
        Found in app/models/privileges/organizer.rb - About 1 hr to fix

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

            def translated_age_range(a_birth_date)
              return '' unless a_birth_date.respond_to?(:beginning_of_day)
          
              date = a_birth_date.beginning_of_day
              today = DateTime.current.beginning_of_day
          Severity: Minor
          Found in app/helpers/diversity_helper.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

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

            def handle_json_response
              result = yield
              json_track = {
                translations: @conference.languages.map do |l|
                  c = @track.translated_contents.where(language: l[:code]).first
          Severity: Major
          Found in app/controllers/tracks_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/audience_levels_controller.rb on lines 71..83

          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

            def handle_json_response
              result = yield
              json_level = {
                translations: @conference.languages.map do |l|
                  c = @audience_level.translated_contents.where(language: l[:code]).first
          Severity: Major
          Found in app/controllers/audience_levels_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/tracks_controller.rb on lines 71..83

          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

          Method privileges has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def privileges
                can!(:create, Session) do
                  @conference.in_submission_phase? &&
                    (@conference.submission_limit.zero? || @user.sessions_for_conference(@conference).active.count < @conference.submission_limit)
                end
          Severity: Minor
          Found in app/models/privileges/author.rb - About 1 hr to fix

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

                execute %(ssh -p #{@port} #{key_param} #{@user}@#{@target} 'mkdir -p #{File.dirname("#{REMOTE_SHARED_FOLDER}/#{file}")}')
                execute %(scp -P #{@port} #{key_param} #{tag_with_target(file)} #{@deployed_user}@#{@target}:#{REMOTE_SHARED_FOLDER}/#{file})
            Severity: Major
            Found in deploy/first_deploy.rb and 1 other location - About 1 hr to fix
            deploy/first_deploy.rb on lines 87..88

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

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

              execute %(ssh -p #{@port} #{key_param} #{@user}@#{@target} 'mkdir -p #{File.dirname("#{REMOTE_SHARED_FOLDER}/#{file}")}')
              execute %(scp -P #{@port} #{key_param} #{tag_with_target(file)} #{@deployed_user}@#{@target}:#{REMOTE_SHARED_FOLDER}/#{file})
            Severity: Major
            Found in deploy/first_deploy.rb and 1 other location - About 1 hr to fix
            deploy/first_deploy.rb on lines 92..93

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

            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 validate_each has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def validate_each(record, attribute, _value)
                case record.outcome
                when Outcome.find_by(title: 'outcomes.accept.title')
                  record.errors.add(attribute, :cant_accept) unless
                    record.session.try(:pending_confirmation?) ||
            Severity: Minor
            Found in app/models/validators/session_acceptance_validator.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 to_tag_keys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_tag_keys(tag_list)
                return nil if tag_list.blank?
            
                tag_names = tag_list.split(/\s*,\s*/)
                return nil if tag_names.empty?
            Severity: Minor
            Found in app/models/session_filter.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

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

              def contents_matching_conference_languages
                translated_languages = translated_contents.map(&:language).compact.map(&:to_sym)
                missing_languages = (conference.try(:supported_languages) || []) - translated_languages
                return if missing_languages.empty?
            
            
            Severity: Major
            Found in app/models/track.rb and 2 other locations - About 40 mins to fix
            app/models/audience_level.rb on lines 24..30
            app/models/session_type.rb on lines 57..63

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

            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

              def contents_matching_conference_languages
                translated_languages = translated_contents.map(&:language).compact.map(&:to_sym)
                missing_languages = (conference.try(:supported_languages) || []) - translated_languages
                return if missing_languages.empty?
            
            
            Severity: Major
            Found in app/models/session_type.rb and 2 other locations - About 40 mins to fix
            app/models/audience_level.rb on lines 24..30
            app/models/track.rb on lines 30..36

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

            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

              def contents_matching_conference_languages
                translated_languages = translated_contents.map(&:language).compact.map(&:to_sym)
                missing_languages = (conference.try(:supported_languages) || []) - translated_languages
                return if missing_languages.empty?
            
            
            Severity: Major
            Found in app/models/audience_level.rb and 2 other locations - About 40 mins to fix
            app/models/session_type.rb on lines 57..63
            app/models/track.rb on lines 30..36

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

            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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def index
                    conferences = Conference.all
                    length = conferences.map { |c| (c.submissions_deadline.to_date - c.submissions_open.to_date).to_i }.max
            
                    conf_distribution = conferences.map do |c|
            Severity: Minor
            Found in app/controllers/api/v1/submissions_controller.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