File cli.rb
has 442 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'optparse'
require 'set'
require 'open-uri'
require 'fileutils'
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
- Read upRead up
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
}
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
Method run
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
case @cmd
when 'json'
import_files
when 'daily'
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)
- Read upRead up
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,
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 }
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 }
- Read upRead up
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,
- Read upRead up
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
}
- Read upRead up
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"