Showing 11 of 17 total issues
Class Scraper
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Scraper
NUM_BOOKS_PER_PAGE = 40
NUM_USERS_PER_PAGE = 20
attr_accessor :agent
File scraper.rb
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mechanize'
require 'yasuri'
require 'bookmeter_scraper/book'
require 'bookmeter_scraper/profile'
Method fetch_target_books_from
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def fetch_target_books_from(page, target_year_month)
raise ArgumentError if target_year_month.nil? || page.nil?
target_books = Books.new
1.upto(NUM_BOOKS_PER_PAGE) do |i|
- 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 fetch_read_books_in
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def fetch_read_books_in(target_year_month, user_id)
raise ArgumentError unless user_id =~ USER_ID_REGEX
raise ArgumentError if target_year_month.nil?
result = Books.new
- 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 extract_books
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def extract_books(page)
raise ArgumentError if page.nil?
books = []
1.upto(NUM_BOOKS_PER_PAGE) do |i|
Method extract_books
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def extract_books(page)
raise ArgumentError if page.nil?
books = []
1.upto(NUM_BOOKS_PER_PAGE) do |i|
- 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 fetch_target_books_from
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_target_books_from(page, target_year_month)
raise ArgumentError if target_year_month.nil? || page.nil?
target_books = Books.new
1.upto(NUM_BOOKS_PER_PAGE) do |i|
Method scrape_books_pages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def scrape_books_pages(user_id, uri_method, agent = @agent)
unless user_id =~ USER_ID_REGEX && \
BookmeterScraper.methods.include?(uri_method)
raise ArgumentError
end
- 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 fetch_followings
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fetch_followings(user_id, agent = @agent)
raise ArgumentError unless user_id =~ USER_ID_REGEX
raise ScraperError if agent.nil?
return [] unless agent.logged_in?
- 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 scrape_users_listing_page
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def scrape_users_listing_page(user_id, uri_method, agent = @agent)
raise ArgumentError unless user_id =~ USER_ID_REGEX
raise ArgumentError unless BookmeterScraper.methods.include?(uri_method)
return [] unless agent.logged_in?
- 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 fetch_books
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fetch_books(user_id, uri_method, agent = @agent)
unless user_id =~ USER_ID_REGEX && \
BookmeterScraper.methods.include?(uri_method)
raise ArgumentError
end
- 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"