holderdeord/hdo-site

View on GitHub
lib/hdo/import/cli.rb

Summary

Maintainability
D
2 days
Test Coverage

File cli.rb has 442 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'optparse'
require 'set'
require 'open-uri'
require 'fileutils'

Severity: Minor
Found in lib/hdo/import/cli.rb - About 6 hrs to fix

    Method generate_agreement_stats has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

          def generate_agreement_stats
            all_categories = !!ENV['ALL_CATEGORIES']
            exclude_budget = !!ENV['EXCLUDE_BUDGET']
    
            sessions     = ParliamentSession.where('start_date > ?', Time.parse('2009-08-31')).order(:start_date).to_a
    Severity: Minor
    Found in lib/hdo/import/cli.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

    Class CLI has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class CLI
          AGREEMENT_CONFIG = {
            unit: :propositions,
            ignore_unanimous: true
          }
    Severity: Minor
    Found in lib/hdo/import/cli.rb - About 3 hrs to fix

      Method generate_agreement_stats has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def generate_agreement_stats
              all_categories = !!ENV['ALL_CATEGORIES']
              exclude_budget = !!ENV['EXCLUDE_BUDGET']
      
              sessions     = ParliamentSession.where('start_date > ?', Time.parse('2009-08-31')).order(:start_date).to_a
      Severity: Major
      Found in lib/hdo/import/cli.rb - About 2 hrs to fix

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

              def run
                case @cmd
                when 'json'
                  import_files
                when 'daily'
        Severity: Minor
        Found in lib/hdo/import/cli.rb - About 1 hr to fix

          Method each_parliament_issue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def each_parliament_issue(parliament_issues, limit = nil)
                  count = 0
          
                  parliament_issues.each_with_index do |parliament_issue, index|
                    details = parsing_data_source.parliament_issue_details(parliament_issue.external_id)
          Severity: Minor
          Found in lib/hdo/import/cli.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 import_api_representatives has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def import_api_representatives
                  representatives = {}
                  representatives_today = []
          
                  # the information in 'representatives_today' is more complete,
          Severity: Minor
          Found in lib/hdo/import/cli.rb - About 1 hr to fix

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

                  def generate_agreement_for_category
                    category_name = ENV['CATEGORY_NAME'] || abort('must set CATEGORY_NAME')
            
                    pis_by_session = Category.where(name: category_name).first.parliament_issues.group_by { |pi| pi.parliament_session_name }
            
            
            Severity: Minor
            Found in lib/hdo/import/cli.rb - About 1 hr to fix

              Method generate_agreement_for_category has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_agreement_for_category
                      category_name = ENV['CATEGORY_NAME'] || abort('must set CATEGORY_NAME')
              
                      pis_by_session = Category.where(name: category_name).first.parliament_issues.group_by { |pi| pi.parliament_session_name }
              
              
              Severity: Minor
              Found in lib/hdo/import/cli.rb - About 35 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 import_api_representatives has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def import_api_representatives
                      representatives = {}
                      representatives_today = []
              
                      # the information in 'representatives_today' is more complete,
              Severity: Minor
              Found in lib/hdo/import/cli.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_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def parse_options(args)
                      options = {
                        :period  => ParliamentPeriod.current ? ParliamentPeriod.current.external_id : nil,
                        :session => ParliamentSession.current ? ParliamentSession.current.external_id : nil
                      }
              Severity: Minor
              Found in lib/hdo/import/cli.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

              There are no issues that match your filters.

              Category
              Status