dtsato/agile_brazil

View on GitHub

Showing 52 of 52 total issues

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

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

  def update
    @audience_level = resource_class.where(id: params[:id]).first
    respond_with @audience_level do |format|
      format.html do
        handle_html_response(t('flash.audience_level.update.success')) { @audience_level.update(audience_level_params) }
Severity: Minor
Found in app/controllers/audience_levels_controller.rb and 2 other locations - About 35 mins to fix
app/controllers/session_types_controller.rb on lines 21..27
app/controllers/tracks_controller.rb on lines 21..27

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

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

  def update
    @track = resource_class.where(id: params[:id]).first
    respond_with @track do |format|
      format.html do
        handle_html_response(t('flash.track.update.success')) { @track.update(track_params) }
Severity: Minor
Found in app/controllers/tracks_controller.rb and 2 other locations - About 35 mins to fix
app/controllers/audience_levels_controller.rb on lines 21..27
app/controllers/session_types_controller.rb on lines 21..27

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

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

  def update
    @session_type = resource_class.where(id: params[:id]).first
    respond_with @session_type do |format|
      format.html do
        handle_html_response(t('flash.session_type.update.success')) { @session_type.update(session_type_params) }
Severity: Minor
Found in app/controllers/session_types_controller.rb and 2 other locations - About 35 mins to fix
app/controllers/audience_levels_controller.rb on lines 21..27
app/controllers/tracks_controller.rb on lines 21..27

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

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

Avoid too many return statements within this method.
Open

    return t('age_range.35_to_39') if today.advance(years: -40) < date
Severity: Major
Found in app/helpers/diversity_helper.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return t('age_range.45_to_49') if today.advance(years: -50) < date
    Severity: Major
    Found in app/helpers/diversity_helper.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return t('age_range.55_to_59') if today.advance(years: -60) < date
      Severity: Major
      Found in app/helpers/diversity_helper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return t('age_range.40_to_44') if today.advance(years: -45) < date
        Severity: Major
        Found in app/helpers/diversity_helper.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return t('age_range.50_to_54') if today.advance(years: -55) < date
          Severity: Major
          Found in app/helpers/diversity_helper.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return t('age_range.30_to_34') if today.advance(years: -35) < date
            Severity: Major
            Found in app/helpers/diversity_helper.rb - About 30 mins to fix

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

                def organizer_section_for(_user, _conference)
                  section = Section.new t('actions.section.organize')
              
                  section.add t('actions.manage_conferences'), conferences_path if can? :read, Conference
                  section.add t('actions.manage_organizers'), organizers_path(@conference) if can? :read, Organizer
              Severity: Minor
              Found in app/helpers/actions_helper.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 2 locations. Consider refactoring.
              Open

                  @conference.supported_languages.each do |code|
                    @new_track.translated_contents.build(language: code)
                    @new_session_type.translated_contents.build(language: code)
                    @new_audience_level.translated_contents.build(language: code)
                    @new_page.translated_contents.build(language: code)
              Severity: Minor
              Found in app/controllers/conferences_controller.rb and 1 other location - About 25 mins to fix
              app/controllers/conferences_controller.rb on lines 79..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 30.

              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

                    @conference.supported_languages.each do |code|
                      @new_track.translated_contents.build(language: code)
                      @new_session_type.translated_contents.build(language: code)
                      @new_audience_level.translated_contents.build(language: code)
                      @new_page.translated_contents.build(language: code)
              Severity: Minor
              Found in app/controllers/conferences_controller.rb and 1 other location - About 25 mins to fix
              app/controllers/conferences_controller.rb on lines 60..64

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

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

              def setup_droplet(droplet)
                setup = "cd #{ROOT}/config && #{link_files(droplet[:ipv4], 'config.yml')} &&\
                  #{link_files(droplet[:ipv4], 'database.yml')} &&\
                  #{link_files(droplet[:ipv4], 'newrelic.yml')} &&\
                  cd #{ROOT}/certs && #{link_files(droplet[:ipv4], 'server.crt')} &&\
              Severity: Minor
              Found in deploy/digital_ocean/new_machine.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

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

                def apply(scope)
                  scope = scope.for_user(@user_id) if @user_id.present?
                  scope = scope.tagged_with(to_tag_keys(@tags)) if @tags.present?
                  scope = scope.with_state(@state.to_sym) if @state.present?
                  scope = scope.for_tracks(@track_id) if @track_id.present?
              Severity: Minor
              Found in app/models/session_filter.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

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

                def reviewer_section_for(user, conference, safe_params)
                  section = Section.new t('actions.section.review')
                  if (conference.in_early_review_phase? ||
                        conference.in_final_review_phase?) &&
                     can?(:read, 'reviewer_sessions')
              Severity: Minor
              Found in app/helpers/actions_helper.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

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

                def sections_for(user, conference, safe_filter_params)
                  sections = []
              
                  sections << session_section_for(user, conference) if user_signed_in?
                  sections << reviewer_section_for(user, conference, safe_filter_params) if user.reviewer? || user.admin?
              Severity: Minor
              Found in app/helpers/actions_helper.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

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

                def title
                  translated_contents.find { |c| c.language.to_sym == I18n.locale.to_sym }.try(:title) ||
                    translated_contents.first.try(:title) ||
                    I18n.t(self[:title] || '')
                end
              Severity: Minor
              Found in app/models/page.rb and 1 other location - About 20 mins to fix
              app/models/page.rb on lines 22..26

              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

                def content
                  translated_contents.find { |c| c.language.to_sym == I18n.locale.to_sym }.try(:content) ||
                    translated_contents.first.try(:content) ||
                    I18n.t(self[:content] || '')
                end
              Severity: Minor
              Found in app/models/page.rb and 1 other location - About 20 mins to fix
              app/models/page.rb on lines 16..20

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

                def description
                  translated_contents.find { |c| c.language.to_sym == I18n.locale.to_sym }.try(:content) || (self[:description] && I18n.t(self[:description])) || ''
                end
              Severity: Minor
              Found in app/models/audience_level.rb and 5 other locations - About 20 mins to fix
              app/models/audience_level.rb on lines 14..16
              app/models/session_type.rb on lines 17..19
              app/models/session_type.rb on lines 21..23
              app/models/track.rb on lines 16..18
              app/models/track.rb on lines 20..22

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

              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