kymmt90/bookmeter_scraper

View on GitHub

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
Severity: Minor
Found in lib/bookmeter_scraper/scraper.rb - About 2 hrs to fix

    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'
    Severity: Minor
    Found in lib/bookmeter_scraper/scraper.rb - About 2 hrs to fix

      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|
      Severity: Minor
      Found in lib/bookmeter_scraper/scraper.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 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
      Severity: Minor
      Found in lib/bookmeter_scraper/scraper.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 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|
      Severity: Minor
      Found in lib/bookmeter_scraper/scraper.rb - About 1 hr to fix

        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|
        Severity: Minor
        Found in lib/bookmeter_scraper/scraper.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 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|
        Severity: Minor
        Found in lib/bookmeter_scraper/scraper.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in lib/bookmeter_scraper/scraper.rb - About 45 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 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?
          
          
          Severity: Minor
          Found in lib/bookmeter_scraper/scraper.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 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?
          
          
          Severity: Minor
          Found in lib/bookmeter_scraper/scraper.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 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
          Severity: Minor
          Found in lib/bookmeter_scraper/scraper.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