fairplaysk/datacamp

View on GitHub

Showing 350 of 350 total issues

Method save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def save
      procurement_digest = digest

      # TODO refactor
      case dataset_type
Severity: Minor
Found in lib/etl/vvo_extraction_v2.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

Function offset has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    jQuery.fn.offset = function( options ) {
        var elem = this[0];

        if ( options ) { 
            return this.each(function( i ) {
Severity: Major
Found in app/assets/javascripts/jquery.js - About 2 hrs to fix

    Class Generator has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Generator
    
        attr_reader :locale, :locale_path
    
        def initialize(locale, locale_path)
    Severity: Minor
    Found in lib/site_map_generator.rb - About 2 hrs to fix

      Method page_entries_info_custom has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def page_entries_info_custom(collection, options = {})
          model = options[:model]
          model = collection.first.class unless model or collection.empty?
          model ||= 'entry'
          model_key = if model.respond_to? :model_name
      Severity: Major
      Found in app/helpers/i18n_helper.rb - About 2 hrs to fix

        Method update_source_url_and_document_id has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.update_source_url_and_document_id(sta_procurement, all_bulletins)
              key = "#{sta_procurement.bulletin_id}/#{sta_procurement.year}"
              url = all_bulletins[key]
        
              document = Nokogiri::HTML(Typhoeus::Request.get(url).body)
        Severity: Minor
        Found in lib/etl/vvo_extraction.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 digest has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def digest(doc)
              ico = name = legal_form = date_start = date_end = address = region = ''
              doc.xpath("//table[@class='tabid']//tr").each do |row|
                if row.xpath(".//td[1]").inner_text.match(/i(Č|č|c)o/i)
                  ico = row.xpath(".//td[3]").inner_text
        Severity: Minor
        Found in lib/etl/regis_extraction_old.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

        Function init_tabs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var init_tabs = function(){
          $("ul.tabs").each(function(){
            // Add init class
            if($(this).hasClass('initialized'))
            {
        Severity: Major
        Found in app/assets/javascripts/inscription.js - About 2 hrs to fix

          Function on has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      function on(e){    
                  
                          $('body').append('<div id="'+s.tooltipID+'" style="background-repeat:no-repeat;background-image:url('+s.tooltipBGImage+');padding:'+s.tooltipPadding+'px;display:none;height:'+s.height+';width:'+s.width+';background-color:'+s.tooltipBGColor+';border:'+s.borderSize+'px solid '+s.borderColor+'; position:absolute;z-index:100000000000;"><div id="tooltipContent" style="display:none;"></div></div>');
                          
                          var $tt = $('#'+s.tooltipID);
          Severity: Major
          Found in app/assets/javascripts/jquery.tooltip.js - About 2 hrs to fix

            Method add_to_sphinx_search has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def add_to_sphinx_search(operand, sphinx_search)
              options = {with: {}, without: {}}
              operand ||= "*"
              
              case operator
            Severity: Major
            Found in app/models/search_predicate.rb - About 2 hrs to fix

              File jquery.asmselect.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * Alternate Select Multiple (asmSelect) 1.0.4a beta - jQuery Plugin
               * http://www.ryancramer.com/projects/asmselect/
               * 
               * Copyright (c) 2009 by Ryan Cramer - http://www.ryancramer.com
              Severity: Minor
              Found in app/assets/javascripts/jquery.asmselect.js - About 2 hrs to fix

                Function modal has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                $.modal = function(options){
                  inscription_modal_remove();
                  
                  options = $.extend({
                    position: 'center',
                Severity: Minor
                Found in app/assets/javascripts/inscription.js - About 2 hrs to fix

                  Method digest has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def digest(doc)
                        ico = name = legal_form = date_start = date_end = address = region = ''
                        doc.xpath("//table[@class='tabid']//tr").each do |row|
                          if row.xpath(".//td[1]").inner_text.match(/i(Č|č|c)o/i)
                            ico = row.xpath(".//td[3]").inner_text
                  Severity: Minor
                  Found in lib/etl/regis_extraction_old.rb - About 2 hrs to fix

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

                        def self.get_path(path, options = {})
                          defaults = {
                            :bucketize => true
                          }
                          options = defaults.merge(options)
                    Severity: Major
                    Found in app/models/parsers/support.rb and 1 other location - About 1 hr to fix
                    lib/etl/vvo_bulletin_downloader.rb on lines 98..116

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

                    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

                        def self.get_path(path, options = {})
                          defaults = {
                              :bucketize => true
                          }
                          options = defaults.merge(options)
                    Severity: Major
                    Found in lib/etl/vvo_bulletin_downloader.rb and 1 other location - About 1 hr to fix
                    app/models/parsers/support.rb on lines 32..50

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

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

                          def self.parse(html, year)
                            ::Parsers::Support.save(parse_location(year), 'csv', bucketize: false)
                            CSV.open(::Parsers::Support.get_path(parse_location(year), bucketize: false), "wb", force_quotes: true) do |csv|
                              csv << ATTRIBUTES
                    
                    
                    Severity: Minor
                    Found in app/models/parsers/donations_parser/parser.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 record_changes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def record_changes
                        if !self.class.table_name.match(/^(rel_|dc_)/) && !is_part_of_import
                          change_details = []
                          changed_attributes.each do |attribute, old_value|
                            next if attribute == "updated_at"
                    Severity: Minor
                    Found in app/models/dataset/dataset_record.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 digest has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def digest(doc)
                          lawyer_table = doc.xpath("//div[@class='section']/table[@class='filter']").first
                    
                          original_name = lawyer_table.xpath('./tr[1]/td[2]').inner_text.strip
                          name_ary = original_name.split
                    Severity: Minor
                    Found in lib/etl/lawyer_extraction.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 save has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def save
                          procurement_digest = digest
                    
                          # TODO refactor
                          case dataset_type
                    Severity: Minor
                    Found in lib/etl/vvo_extraction_v2.rb - About 1 hr to fix

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

                              if ( jQuery.isFunction(value) ) {
                                  return this.each(function(i) {
                                      var self = jQuery(this);
                                      self.removeClass( value.call(this, i, self.attr("class")) );
                                  });
                      Severity: Major
                      Found in app/assets/javascripts/jquery.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/jquery.js on lines 1465..1470

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

                      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 ( jQuery.isFunction(value) ) {
                                  return this.each(function(i) {
                                      var self = jQuery(this);
                                      self.addClass( value.call(this, i, self.attr("class")) );
                                  });
                      Severity: Major
                      Found in app/assets/javascripts/jquery.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/jquery.js on lines 1501..1506

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

                      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