moser/foxtrot_mike

View on GitHub

Showing 90 of 90 total issues

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

                    right: dim.s.rect.right - dim.s.border.right - dim.s.scrollbar.right - dim.e.rect.right
Severity: Major
Found in app/assets/javascripts/jquery_scrollintoview.js and 1 other location - About 1 hr to fix
app/assets/javascripts/jquery_scrollintoview.js on lines 108..108

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

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

                    bottom: dim.s.rect.bottom - dim.s.border.bottom - dim.s.scrollbar.bottom - dim.e.rect.bottom,
Severity: Major
Found in app/assets/javascripts/jquery_scrollintoview.js and 1 other location - About 1 hr to fix
app/assets/javascripts/jquery_scrollintoview.js on lines 110..110

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

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 group has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def group(flights, enable, &block)
    if enable
      flights = flights.dup
      while !flights.empty? do
        current = flights.first.aggregation_id
Severity: Minor
Found in app/helpers/filtered_flights_helper.rb - About 1 hr to fix

    Function insert has 36 lines of code (exceeds 25 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 1 hr to fix

      Method soft_validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def soft_validate
          self.problems = {}
          problems[:too_many_people] = {} if too_many_people_for_plane?
          problems[:seat2_is_not_an_instructor] = {} if seat2_not_an_instructor?
          problems[:launch_method_impossible] = {} if launch_method_impossible?
      Severity: Minor
      Found in app/models/abstract_flight.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_accounting_entries has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_accounting_entries
          accounting_entries_without_validity_check.destroy_all
          if cost && cost_responsible
            plane_account = plane.financial_account_at(departure_date)
            flight_sum = cost.free_sum
      Severity: Minor
      Found in app/models/flight.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 group has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def group(flights, enable, &block)
          if enable
            flights = flights.dup
            while !flights.empty? do
              current = flights.first.aggregation_id
      Severity: Minor
      Found in app/helpers/filtered_flights_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

            if(matches != null && matches.length == 6) {
              obj = {m: this.integer(matches[1]), d: this.integer(matches[3]), y: this.integer(matches[5]) };
            } else {
              return false;
            }
      Severity: Major
      Found in app/assets/javascripts/app.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/app.js on lines 17..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 63.

      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

          if(matches != null && matches.length == 4) {
            obj = {m: this.integer(matches[2]), d: this.integer(matches[1]), y: this.integer(matches[3]) };
          } else {
            matches = this.date_pattern_en.exec(str);
            if(matches != null && matches.length == 6) {
      Severity: Major
      Found in app/assets/javascripts/app.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/app.js on lines 21..25

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

      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

      Function parseUri has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function parseUri(str) {
          var    o   = parseUri.options,
              m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
              uri = {},
              i   = 14;
      Severity: Minor
      Found in app/assets/javascripts/app.js - About 1 hr to fix

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

          def format_currency(i, show_unit = true)
            "#{(i < 0) ? '-' : ''}#{(i.abs/100.0).to_i},#{i.abs%100 < 10 ? "0" : ""}#{i.abs%100}#{ show_unit ? ' €' : ''}" unless i.nil? #TODO i18n/configurable
          end
        Severity: Minor
        Found in app/helpers/application_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

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

          def lvb_member_state(date = Date.today)
            unless primary_member
              :secondary
            else
              if active?
        Severity: Minor
        Found in app/models/person.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 distance has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def distance(str2)
            str1 = self.downcase
            str2 = str2.downcase
            if $KCODE =~ /^U/i
              unpack_rule = 'U*'
        Severity: Minor
        Found in lib/core_ext.rb - About 1 hr to fix

          Method initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(account)
              if account
                if account.admin?
                  can :manage, :all
                else
          Severity: Minor
          Found in app/models/ability.rb - About 1 hr to fix

            Method show has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def show
                @airfield = Airfield.find(params[:airfield_id])
                authorize! :read, @airfield
                @date = parse_date(params[:filter], :date) || AbstractFlight.latest_departure(@airfield.flights).to_date
                if params[:as] == 'controller_log'
            Severity: Minor
            Found in app/controllers/main_log_books_controller.rb - About 1 hr to fix

              Function scrollable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      scrollable: function (element, index, meta, stack) {
                          var direction = converter[typeof (meta[3]) === "string" && meta[3].toLowerCase()] || converter.both;
                          var styles = (document.defaultView && document.defaultView.getComputedStyle ? document.defaultView.getComputedStyle(element, null) : element.currentStyle);
                          var overflow = {
                              x: scrollValue[styles.overflowX.toLowerCase()] || false,
              Severity: Minor
              Found in app/assets/javascripts/jquery_scrollintoview.js - About 1 hr to fix

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

                  def parse_json_dates(obj)
                   if obj.is_a?(Hash)
                      obj.keys.each do |k|
                        obj[k] = parse_json_dates(obj[k])
                      end
                Severity: Minor
                Found in app/controllers/application_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 matches? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def matches?(flight, conditions = nil)
                    if flight.launch && flight.launch.is_a?(WireLaunch)
                      unless conditions
                        valid_at?(flight.departure) && matches?(flight, [ person_cost_category, wire_launcher_cost_category, cost_rule_conditions ].flatten)
                      else
                Severity: Minor
                Found in app/models/wire_launch_cost_rule.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 init has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def init
                    self.default_launch_method ||= "self_launch"
                    self.competition_sign ||= ""
                    self.seat_count = 1 if seat_count.nil?
                    self.has_engine = false if has_engine.nil?
                Severity: Minor
                Found in app/models/plane.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 finished= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def finished=(b)
                    unless !b || finished?
                      flights.each do |f|
                        f.update_attribute :accounting_session, self
                        f.accounting_entries.each do |e|
                Severity: Minor
                Found in app/models/accounting_session.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

                Severity
                Category
                Status
                Source
                Language