sleepepi/sleepportal

View on GitHub

Showing 436 of 436 total issues

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

  def directional_do!(position, direction)
    current_position = self.history_position + position
    if current_position >= 0 and current_position < self.history.size
      history_hash = self.history[current_position].symbolize_keys
      qc = Criterium.find_by_id(history_hash[:id])
Severity: Minor
Found in app/models/search.rb - About 1 hr to fix

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

      def import_variables(file_name)
        version = Time.now.to_i.to_s
    
        CSV.parse( File.open(file_name, 'r:iso-8859-1:utf-8'){|f| f.read}, headers: true ) do |line|
          row = line.to_hash
    Severity: Minor
    Found in app/models/dictionary.rb - About 1 hr to fix

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

          when 'choices'
            values = values.sort{|a,b|( a and b ) ? a <=> b : ( a ? -1 : 1 ) }.group_by{|val| val}.collect do |key, array|
              { name: "#{self.human_normalized_value(key)} in #{self.source.name} at #{self.human_table}", y: array.size, id: key.to_s, mapping_id: self.id }
      Severity: Major
      Found in app/models/mapping.rb and 1 other location - About 1 hr to fix
      app/models/mapping.rb on lines 115..117

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

      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

          when 'choices'
            values = values.sort{|a,b|( a and b ) ? a <=> b : ( a ? -1 : 1 ) }.group_by{|val| val}.collect do |key, array|
              { name: "#{self.human_normalized_value(key)} in #{self.source.name} at #{self.human_table}", y: array.size, id: key.to_s, mapping_id: self.id }
      Severity: Major
      Found in app/models/mapping.rb and 1 other location - About 1 hr to fix
      app/models/mapping.rb on lines 81..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 51.

      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

                      window.setTimeout(this.bind(function() { this.search.attr("tabIndex", this.opts.element.attr("tabIndex")); }), 10);
      Severity: Major
      Found in app/assets/javascripts/external/select2.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/external/select2.js on lines 1485..1485

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

      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

                      window.setTimeout(this.bind(function() { this.selection.attr("tabIndex", this.opts.element.attr("tabIndex")); }), 10);
      Severity: Major
      Found in app/assets/javascripts/external/select2.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/external/select2.js on lines 1513..1513

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

      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 vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1];
      Severity: Major
      Found in app/assets/javascripts/external/jquery.sparkline.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/external/jquery.sparkline.js on lines 489..489

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

      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 vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 :  values[vl-1];
      Severity: Major
      Found in app/assets/javascripts/external/jquery.sparkline.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/external/jquery.sparkline.js on lines 486..486

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

      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 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @dictionary = current_user.dictionaries.new(dictionary_params)
      
          if @dictionary.save
            unless params[:domains_file].blank?
      Severity: Minor
      Found in app/controllers/dictionaries_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 auto_map has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def auto_map
          if params[:table].blank?
            result_hash = @source.tables(current_user)
            tables = result_hash[:result] || []
          else
      Severity: Minor
      Found in app/controllers/sources_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 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          if @dictionary.update(dictionary_params)
            unless params[:domains_file].blank?
              if params[:domains_file].original_filename =~ /.*\.csv/i
                @dictionary.import_domains(params[:domains_file].tempfile.path)
      Severity: Minor
      Found in app/controllers/dictionaries_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

      Function setOffset has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          setOffset: function (xOffset, xWidth) {
              var stackItem = this,
                  axis = stackItem.axis,
                  chart = axis.chart,
                  inverted = chart.inverted,
      Severity: Minor
      Found in app/assets/javascripts/external/highcharts-3.0.7.src.js - About 1 hr to fix

        Function text has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            text: function (str, x, y, useHTML) {
        
                // declare variables
                var renderer = this,
                    defaultChartStyle = defaultOptions.chart.style,
        Severity: Minor
        Found in app/assets/javascripts/external/highcharts-3.0.7.src.js - About 1 hr to fix

          Function layOutTitles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              layOutTitles: function () {
                  var titleOffset = 0,
                      title = this.title,
                      subtitle = this.subtitle,
                      options = this.options,
          Severity: Minor
          Found in app/assets/javascripts/external/highcharts-3.0.7.src.js - About 1 hr to fix

            Function initReflow has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                initReflow: function () {
                    var chart = this,
                        optionsChart = chart.options.chart,
                        renderTo = chart.renderTo,
                        reflowTimeout;
            Severity: Minor
            Found in app/assets/javascripts/external/highcharts-3.0.7.src.js - About 1 hr to fix

              Function drawGraph has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  drawGraph: function () {
                      
                      // Define or reset areaPath
                      this.areaPath = [];
                      
              Severity: Minor
              Found in app/assets/javascripts/external/highcharts-3.0.7.src.js - About 1 hr to fix

                Function updatePosition has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        updatePosition: function (x, y) {
                            if (x === undefined) {
                                if (this.mousex === undefined) {
                                    return;
                                }
                Severity: Minor
                Found in app/assets/javascripts/external/jquery.sparkline.js - About 1 hr to fix

                  Function resolveContainerWidth has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              function resolveContainerWidth() {
                                  var style, attrs, matches, i, l;
                  
                                  if (this.opts.width === "off") {
                                      return null;
                  Severity: Minor
                  Found in app/assets/javascripts/external/select2.js - About 1 hr to fix

                    Method auto_map has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def auto_map
                        if params[:table].blank?
                          result_hash = @source.tables(current_user)
                          tables = result_hash[:result] || []
                        else
                    Severity: Minor
                    Found in app/controllers/sources_controller.rb - About 1 hr to fix

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

                              if (off > chart.plotHeight) {
                                  if (verticalAlign === 'top') {
                                      options.verticalAlign = 'bottom';
                                  } else {
                                      options.y = chart.plotHeight - off;
                      Severity: Major
                      Found in app/assets/javascripts/external/highcharts-3.0.7.src.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/external/highcharts-3.0.7.src.js on lines 14595..14602

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

                      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