rletters/rletters

View on GitHub

Showing 114 of 114 total issues

File color_brewer.rb has 546 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module RLetters
  module Visualization
    # Color ramps from the ColorBrewer color palettes
    #
    # These are drawn from ColorBrewer, www.ColorBrewer.org, by Cynthia A.
Severity: Major
Found in app/lib/r_letters/visualization/color_brewer.rb - About 1 day to fix

    Method to_mods has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def to_mods(doc, include_namespace = true)
              xml_doc = Nokogiri::XML::Document.new
              mods = Nokogiri::XML::Node.new('mods', xml_doc)
              xml_doc.add_child(mods)
    
    
    Severity: Major
    Found in app/lib/r_letters/documents/serializers/mods.rb - About 5 hrs to fix

      Method to_marc_record has 108 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def to_marc_record(doc)
                record = ::MARC::Record.new
      
                record.append(::MARC::ControlField.new('001', doc.uid))
                record.append(::MARC::ControlField.new('003', 'RLID'))
      Severity: Major
      Found in app/lib/r_letters/documents/serializers/marc_record.rb - About 4 hrs to fix

        Method to_marc_record has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

                def to_marc_record(doc)
                  record = ::MARC::Record.new
        
                  record.append(::MARC::ControlField.new('001', doc.uid))
                  record.append(::MARC::ControlField.new('003', 'RLID'))
        Severity: Minor
        Found in app/lib/r_letters/documents/serializers/marc_record.rb - About 4 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

        Method perform has 100 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def perform(user)
            raise 'Attempted to export a non-user object' unless user.is_a?(User)
        
            # Kill any already attached file
            user.export_archive.purge if user.export_archive.attached?
        Severity: Major
        Found in app/jobs/user_export_job.rb - About 4 hrs to fix

          Method perform has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def perform(task, options = {})
              standard_options(task, options)
          
              # Patch up the two strange arguments that don't come in the right format
              # from the web form
          Severity: Major
          Found in app/jobs/word_frequency_job.rb - About 3 hrs to fix

            Method call has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                  def call
                    case scoring
                    when :log_likelihood
                      score_class = Scoring::LogLikelihood
                    when :mutual_information
            Severity: Minor
            Found in app/lib/r_letters/analysis/cooccurrence.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

            Method group_corpus has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                  def group_corpus
                    ret = {}
                    start = 0
            
                    num_docs = 0
            Severity: Minor
            Found in app/lib/r_letters/analysis/count_articles_by_field.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

            Function createNetworkGraph has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function createNetworkGraph() {
              // Get the elements we need
              var graphContainer = window.jQuery('.network_graph');
              if (graphContainer.length === 0)
                return;
            Severity: Major
            Found in app/assets/javascripts/jobs/network.js - About 3 hrs to fix

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

              function setupTermDatesGraph() {
                // Get the elements we need
                if ($('.term_dates_graph').length === 0 ||
                    $('.term_dates_table').length === 0)
                  return;
              Severity: Major
              Found in app/assets/javascripts/jobs/term_dates.js and 2 other locations - About 3 hrs to fix
              app/assets/javascripts/jobs/article_dates.js on lines 64..75
              app/assets/javascripts/jobs/craig_zeta.js on lines 61..71

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

              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

              function setupArticleDatesGraph() {
                // Get the elements we need
                if ($('.article_dates_graph').length === 0 ||
                    $('.article_dates_table').length === 0)
                  return;
              Severity: Major
              Found in app/assets/javascripts/jobs/article_dates.js and 2 other locations - About 3 hrs to fix
              app/assets/javascripts/jobs/craig_zeta.js on lines 61..71
              app/assets/javascripts/jobs/term_dates.js on lines 52..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 100.

              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

              function setupCraigZetaGraph() {
                // Get the elements we need
                if ($('#cz-graph').length === 0 || $('#cz-table').length === 0)
                  return;
              
              
              Severity: Major
              Found in app/assets/javascripts/jobs/craig_zeta.js and 2 other locations - About 3 hrs to fix
              app/assets/javascripts/jobs/article_dates.js on lines 64..75
              app/assets/javascripts/jobs/term_dates.js on lines 52..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 100.

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

                    def validate!
                      if query.present?
                        # Construct field and value from the query
                        parts = query.split(':')
                        unless parts.size == 2
              Severity: Minor
              Found in app/lib/r_letters/solr/facet.rb - About 2 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

              Method year_ranges_query has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                    private_class_method def self.year_ranges_query(year_ranges)
                      # Strip whitespace, split on commas
                      ranges = year_ranges.gsub(/\s/, '').split(',')
                      year_queries = []
              
              
              Severity: Minor
              Found in app/lib/r_letters/solr/advanced.rb - About 2 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

              Method frequencies has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                    def frequencies
                      analyzer = Frequency.call(
                        dataset: dataset,
                        stemming: stemming,
                        block_size: window,
              Severity: Minor
              Found in app/lib/r_letters/analysis/cooccurrence.rb - About 2 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

              Method grouped_uids_corpus has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                    def grouped_uids_corpus
                      ret = {}
                      start = 0
              
                      num_docs = 0
              Severity: Minor
              Found in app/lib/r_letters/analysis/count_terms_by_field.rb - About 2 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

              Method perform has 65 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def perform(task, options)
                  standard_options(task, options)
              
                  unless datasets.size == 2
                    raise ArgumentError, 'Wrong number of other datasets provided'
              Severity: Major
              Found in app/jobs/craig_zeta_job.rb - About 2 hrs to fix

                Method journal_list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def journal_list
                      ret = []
                      offset = 0
                
                      loop do
                Severity: Minor
                Found in app/controllers/admin/categories_controller.rb - About 2 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

                Method to_mods has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                        def to_mods(doc, include_namespace = true)
                          xml_doc = Nokogiri::XML::Document.new
                          mods = Nokogiri::XML::Node.new('mods', xml_doc)
                          xml_doc.add_child(mods)
                
                
                Severity: Minor
                Found in app/lib/r_letters/documents/serializers/mods.rb - About 2 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

                Method for has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.for(lang)
                        filename = Rails.root.join('app', 'lib', 'r_letters', 'analysis',
                                                   'stop_list', "stopwords_#{lang}.txt")
                        return nil unless File.exist?(filename)
                
                
                Severity: Minor
                Found in app/lib/r_letters/analysis/stop_list.rb - About 2 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

                Severity
                Category
                Status
                Source
                Language