fairplaysk/datacamp

View on GitHub

Showing 277 of 350 total issues

Avoid too many return statements within this function.
Open

        return i === al ?
            siblingCheck( a, bp[i], -1 ) :
            siblingCheck( ap[i], b, 1 );
Severity: Major
Found in app/assets/javascripts/jquery.js - About 30 mins to fix

    Method restore has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def restore
          @account = User.find_by_restoration_code(params[:id] || ".")
          if request.put?
            user = params[:user]
            if user[:password].present? && user[:password] == user[:password_confirmation]
    Severity: Minor
    Found in app/controllers/settings/users_controller.rb - About 25 mins 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 searched_datasets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def searched_datasets
        datasets = DatasetDescription.where(:is_active => true)
        
        Rails.logger.info "search: find datasets"
    
    
    Severity: Minor
    Found in app/models/search_query.rb - About 25 mins 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 new_from_session has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.new_from_session(session, request)
        begin
          self.current_session = self.find_or_create_by_session_id(session[:session_id])
        rescue
          begin
    Severity: Minor
    Found in app/models/session.rb - About 25 mins 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 parse_recipient_2007_2012 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def self.parse_recipient_2007_2012(td)
              proposal = {}
              e = td.css('span.cervene').first
              return proposal unless e
              proposal[:name] = clean_string(e.text)
    Severity: Minor
    Found in app/models/parsers/donations_parser/parser.rb - About 25 mins 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 build_sphinx_search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_sphinx_search(search, sphinx_search)
        search.query.predicates.each do |predicate|
          field_description = field_descriptions.find_by_identifier(predicate.search_field)
          operand = field_description.is_derived ? field_description.derived_value : field_description.identifier if field_description
          sphinx_search = predicate.add_to_sphinx_search(operand, sphinx_search)
    Severity: Minor
    Found in app/models/dataset_description.rb - About 25 mins 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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        search_params = params[:search] || {}
        if search_params[:predicates]
          query = SearchQuery.query_with_predicates(create_predicates_from_hash(search_params[:predicates]), :scope => "dataset", :object => search_params[:dataset])
          search = Search.create(:query => query, :search_type => 'predicates', :session => @current_session)
    Severity: Minor
    Found in app/controllers/searches_controller.rb - About 25 mins 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 download_procurements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.download_procurements(link_match, year_match)
          agent = Mechanize.new
          agent.get(SEARCH_URL)
          if year_match
            link_element = agent.page.link_with(text: year_match)
    Severity: Minor
    Found in lib/etl/vvo_checker_v2.rb - About 25 mins 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 delete_relationship has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def delete_relationship
        dataset_description = DatasetDescription.find(params[:dataset_id])
        record = dataset_description.dataset_model.find_by_record_id(params[:id])
        if params[:macro] == 'has_many'
          related_dataset_description = DatasetDescription.find(params[:related_dataset])
    Severity: Minor
    Found in app/controllers/records_controller.rb - About 25 mins 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 all_bulletins_in_year has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.all_bulletins_in_year(in_year)
          document_url = "http://www2.uvo.gov.sk/sk/evestnik/-/vestnik/all"
          document = Nokogiri::HTML(Typhoeus::Request.get(document_url).body)
    
          links = []
    Severity: Minor
    Found in lib/etl/vvo_bulletin_extraction.rb - About 25 mins 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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        @data_repair = DataRepair.find(params[:id])
        begin
          @data = get_preview_data(@data_repair)
        rescue
    Severity: Minor
    Found in app/controllers/data_repairs_controller.rb - About 25 mins 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_founders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def digest_founders(table)
            founders = []
            table.xpath(".//tr").each do |founder_row|
              founder_identification = founder_row.xpath(".//td[1]").inner_text.strip.split("\n")
              founder_contribution = founder_row.xpath(".//td[3]").inner_text[1..-2].strip.split(' ')
    Severity: Minor
    Found in lib/etl/foundation_extraction.rb - About 25 mins 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 build_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_attributes(values)
          attributes = {}
    
          values.each_with_index do |value, index|
    
    
    Severity: Minor
    Found in app/services/csv_import/mapper.rb - About 25 mins 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 extract_procurements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.extract_procurements(type, year)
          procurements = []
          LINKS[type].each do |link|
            link_match = %r{#{"#{link} (.*)"}}
            year_match = year ? %r{#{"#{year} (.*)"}} : nil
    Severity: Minor
    Found in lib/etl/vvo_checker_v2.rb - About 25 mins 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_search_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def init_search_object
        if params[:search_id].present?
          @search_predicates = Search.find_by_id(params[:search_id]).query.predicates
        elsif params[:controller] == 'searches' && params[:id].present?
          search = Search.find_by_id(params[:id])
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 25 mins 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 related_records_and_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def related_records_and_fields(dataset_description, record)
        @dataset_class.reflect_on_all_associations.delete_if{ |a| a.name =~ /^dc_/ }.map do |reflection|
          dd = DatasetDescription.find_by_identifier(
              Dataset::Naming.association_name_to_identifier(reflection.name)
          )
    Severity: Minor
    Found in app/controllers/records_controller.rb - About 25 mins 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 all_bulletins_in_year has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.all_bulletins_in_year(in_year)
          document_url = ALL_BULLETINS_URL
          document = Nokogiri::HTML(Typhoeus::Request.get(document_url).body)
    
          links = {}
    Severity: Minor
    Found in lib/etl/vvo_bulletin_extraction_v2.rb - About 25 mins 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