fairplaysk/datacamp

View on GitHub

Showing 350 of 350 total issues

Method parse_price2 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_price2(price_element)
        price_hash = {}
        price_elements = price_element.xpath(".//span[@class='hodnota']")
        if price_elements.size == 1
          price_hash[:price] = parse_float(price_elements[0].inner_text.strip)
Severity: Minor
Found in lib/etl/vvo_v2/parser_includes.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 data has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    data: function( key, value ) {
        var data = null;

        if ( typeof key === "undefined" ) {
            if ( this.length ) {
Severity: Minor
Found in app/assets/javascripts/jquery.js - About 1 hr to fix

    Function hashchangeLoader has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            hashchangeLoader: function () {
                var History = $.History;
                
                // More is needed for non IE8 browsers
                if ( !($.browser.msie && parseInt($.browser.version) >= 8) ) {    
    Severity: Minor
    Found in app/assets/javascripts/jquery.history.js - About 1 hr to fix

      Method parse_price2 has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def parse_price2(price_element)
              price_hash = {}
              price_elements = price_element.xpath(".//span[@class='hodnota']")
              if price_elements.size == 1
                price_hash[:price] = parse_float(price_elements[0].inner_text.strip)
      Severity: Minor
      Found in lib/etl/vvo_v2/parser_includes.rb - About 1 hr to fix

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

            def perform
              document_ids = {
                  notice: [],
                  performance: []
              }
        Severity: Minor
        Found in lib/etl/vvo_bulletin_extraction_v2.rb - About 1 hr to fix

          Method parse_price1 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def parse_price1(price_element)
                  price_hash = {}
                  if price_element.xpath(".//span").size == 1
                    price_hash[:price] = parse_float(price_element.xpath(".//span[1]").inner_text.strip)
                    price_hash[:price_interval] = false
          Severity: Minor
          Found in lib/etl/vvo_v2/parser_includes.rb - About 1 hr to fix

            Function addListItem has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        function addListItem(optionId) {
            
                            // add a new item to the html list
            
                            var $O = $('#' + optionId); 
            Severity: Minor
            Found in app/assets/javascripts/jquery.asmselect.js - About 1 hr to fix

              Method digest has 36 lines of code (exceeds 25 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

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

                  Function fix has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      fix: function( event ) {
                          if ( event[ jQuery.expando ] ) {
                              return event;
                          }
                  
                  
                  Severity: Minor
                  Found in app/assets/javascripts/jquery.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if ( match[1] === "nth" ) {
                                    // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
                                    var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
                                        match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
                                        !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
                    Severity: Critical
                    Found in app/assets/javascripts/jquery.js - About 1 hr to fix

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

                              toArray: function(o) {
                      
                                  o = o || {};
                                  var sDepth = o.startDepthCount || 0;
                                  var ret = [];
                      Severity: Minor
                      Found in app/assets/javascripts/jquery.ui.nestedSortable.js - About 1 hr to fix

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

                            def digest(doc)
                              ico = name = place = date_start = date_end = address = region = ''
                        
                              trs = doc.css(".detailTable tr.detailTableRow")
                        
                        
                        Severity: Minor
                        Found in lib/etl/regis_extraction.rb - About 1 hr to fix

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

                              def get_downloads
                                id = 0
                                downloads = []
                                begin
                                  doc_data = Typhoeus::Request.get(@url + id.to_s, disable_ssl_peer_verification: true)
                          Severity: Major
                          Found in lib/etl/lawyer_partnership_extraction.rb and 1 other location - About 1 hr to fix
                          lib/etl/lawyer_associate_extraction.rb on lines 78..88

                          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

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

                              def get_downloads
                                id = 0
                                downloads = []
                                begin
                                  doc_data = Typhoeus::Request.get(@url + id.to_s, disable_ssl_peer_verification: true)
                          Severity: Major
                          Found in lib/etl/lawyer_associate_extraction.rb and 1 other location - About 1 hr to fix
                          lib/etl/lawyer_partnership_extraction.rb on lines 89..99

                          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

                                            elsif span.inner_text.strip.start_with?('Telefón')
                                              customer_information_hash[:customer_phone] = span.next_sibling.next_sibling.inner_text.strip
                                            elsif span.inner_text.strip.start_with?('Fax')
                                              customer_information_hash[:customer_fax] = span.next_sibling.next_sibling.inner_text.strip
                                            elsif span.inner_text.strip.start_with?('Email')
                          Severity: Major
                          Found in lib/etl/vvo_v2/customer_information_parser.rb and 1 other location - About 1 hr to fix
                          lib/etl/vvo_v2/suppliers_information_parser.rb on lines 93..101

                          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

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

                                                if span.inner_text.strip.start_with?('Telefón')
                                                  supplier_hash[:supplier_phone] = span.next_sibling.next_sibling.inner_text.strip
                                                elsif span.inner_text.strip.start_with?('Fax')
                                                  supplier_hash[:supplier_fax] = span.next_sibling.next_sibling.inner_text.strip
                                                elsif span.inner_text.strip.start_with?('Email')
                          Severity: Major
                          Found in lib/etl/vvo_v2/suppliers_information_parser.rb and 1 other location - About 1 hr to fix
                          lib/etl/vvo_v2/customer_information_parser.rb on lines 26..34

                          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

                          Function positionTooltip has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  var positionTooltip = function(e){
                                      
                                      var posx = 0;
                                      var posy = 0;
                                      if (!e) var e = window.event;
                          Severity: Minor
                          Found in app/assets/javascripts/jquery.tooltip.js - About 1 hr to fix

                            Method parse has 32 lines of code (exceeds 25 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

                              Method update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def update
                                  @dataset_description  = DatasetDescription.find_by_id(params[:id])
                                  @dataset_class        = @dataset_description.dataset_model
                              
                                  if params[:record].blank?
                              Severity: Minor
                              Found in app/controllers/datasets_controller.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language