moser/foxtrot_mike

View on GitHub

Showing 90 of 90 total issues

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

  def update
    model_by_id
    authorize! :update, @model
    if @model.update_attributes(params[model_name.underscore.to_sym])
      unless request.xhr?
Severity: Minor
Found in app/controllers/resource_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 import has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.import(hashes)
    ActiveRecord::Base.transaction do
      hashes.each do |hash|
        begin
          import_group(hash)
Severity: Minor
Found in app/models/person.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if not_between_sr_and_ss?
          sr = (from && from.srss? && from.srss.sunrise_i(departure_date)) ||-1
          ss = (to && to.srss? && to.srss.sunset_i(departure_date)) ||-1
          problems[:not_between_sr_and_ss] = { :sr => DayTime.format(sr), :ss => DayTime.format(ss) }
        end
    Severity: Major
    Found in app/models/abstract_flight.rb - About 1 hr to fix

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

        def self.format(minutes)
          if minutes.nil?
            ""
          elsif minutes >= 0
            h, m = [minutes / 60, minutes % 60]
      Severity: Minor
      Found in app/models/day_time.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_accounting_entries has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_accounting_entries
          accounting_entries_without_validity_check.destroy_all
          if cost
            sum = cost.free_sum
            abstract_flight.liabilities_with_default.map do |l|
      Severity: Minor
      Found in lib/launch_accounting_entries.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 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @accounting_session = AccountingSession.find(params[:accounting_session_id])
          authorize! :update, @accounting_session
          if @accounting_session.finished?
            redirect_to [ @accounting_session, :manual_accounting_entries ]
      Severity: Minor
      Found in app/controllers/manual_accounting_entries_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 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @account = Account.find(params[:account_id]) if params[:account_id]
          @account ||= current_account
          @own = @account == current_account
          authorize! :update, @account unless @own
      Severity: Minor
      Found in app/controllers/passwords_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 to_csv has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def to_csv
          CSV.generate(encoding: 'UTF-8', col_sep: "\t") do |csv|
            csv << headers
            @flights.each do |flight|
              csv << [flight.id,
      Severity: Minor
      Found in app/models/flight_exporter.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

      Function date has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        date: function(str) {
          matches = this.date_pattern_de.exec(str);
          if(matches != null && matches.length == 4) {
            obj = {m: this.integer(matches[2]), d: this.integer(matches[1]), y: this.integer(matches[3]) };
          } else {
      Severity: Minor
      Found in app/assets/javascripts/app.js - 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

          return ((d < 10 ? '0': '') + d) + '.' + ((m < 10 ? '0': '') + m) + '.' + date.getFullYear();
      Severity: Minor
      Found in app/assets/javascripts/app.js and 1 other location - About 50 mins to fix
      app/assets/javascripts/app.js on lines 74..75

      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

          return ((d < 10 ? '0': '') + d) + '.' + ((m < 10 ? '0': '') + m) + '.' +
                  date.getFullYear() + ' ' + ((h < 10 ? '0': '') + h) + ':' + ((min < 10 ? '0': '') + min);
      Severity: Minor
      Found in app/assets/javascripts/app.js and 1 other location - About 50 mins to fix
      app/assets/javascripts/app.js on lines 80..80

      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

        def new_link(klass, str = nil, options = {})
          options = merge_class_into_options("new", options)
          unless str
            link_to t('views.new'), polymorphic_path(klass, :action => :new), *[options] if can(:create, klass)
          else
      Severity: Minor
      Found in app/helpers/application_helper.rb and 1 other location - About 45 mins to fix
      app/helpers/application_helper.rb on lines 51..57

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

      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
          @obj = parent
          authorize! :destroy, @obj
          redirect_to "/403.html" if AccountingEntry === @obj && !@obj.manual?
          if @obj.destroy
      Severity: Minor
      Found in app/controllers/destroy_confirmations_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

      Avoid deeply nested control flow statements.
      Open

                  elsif l =~ /([0-9]*) examples*, 0 failures/
                    `notify-send --hint=int:transient:1 '#{$1} example#{$1 == "1" ? "" : "s"} passed' -i ~/code/foxtrot_mike/.notify-img/passed.png &> /dev/null`
                    notified = true
                    if @run_all_when_green && ((DateTime.now - @last_time_all) * 1440) > 5 #only run all after green every 5 minutes
                      #@run_all = true 
      Severity: Major
      Found in autospec.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if @run_all_when_green 
                        #@run_all = true 
                        @run_all_when_green = false
                      end
        Severity: Major
        Found in autospec.rb - About 45 mins to fix

          Method generate_filtered_flights_path has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def generate_filtered_flights_path(obj, from, to, group_by, aggregate_entries, format = :html)
          Severity: Minor
          Found in app/helpers/filtered_flights_helper.rb - About 45 mins to fix

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

              def create
                if types.include?(params[:cost_rule_condition_type])
                  p params[:cost_rule_condition][params[:cost_rule_condition_type].underscore]
                  @cost_rule_condition = params[:cost_rule_condition_type].constantize.new(params[:cost_rule_condition][params[:cost_rule_condition_type].underscore])
                  authorize! :create, @cost_rule_condition
            Severity: Minor
            Found in app/controllers/cost_rule_conditions_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

            Avoid deeply nested control flow statements.
            Open

                          `notify-send --hint=int:transient:1 '#{$1} example#{$1 == "1" ? "" : "s"}, #{$2} pending' -i ~/code/foxtrot_mike/.notify-img/pending.png &> /dev/null`
            Severity: Major
            Found in autospec.rb - About 45 mins to fix

              Function insert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                insert: function(h, target, link) {
                  h.find('a.inline_form_hide').bind('click', function(e) {
                    target.show();
                    h.remove();
                    return false;
              Severity: Minor
              Found in app/assets/javascripts/inline_form.js - 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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def index
                  @person_cost_categories = PersonCostCategory.all
                  @plane_cost_categories = PlaneCostCategory.all
                  @wire_launcher_cost_categories = WireLauncherCostCategory.all
              
              
              Severity: Minor
              Found in app/controllers/cost_rules_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

              Severity
              Category
              Status
              Source
              Language