beneills/legibil

View on GitHub

Showing 3 of 5 total issues

Method grab_page_screenshot_webkit2png has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def grab_page_screenshot_webkit2png(url)
    # generate file names, knowing that webkit2png appends '-full' to the supplied string
    tmp_filename         = new_temporary_image_filename
    screenshot_dir       = File.dirname  tmp_filename
    screenshot_file_base = File.basename tmp_filename, '.png'
Severity: Minor
Found in app/workers/refresh_endpoint_worker.rb - About 1 hr to fix

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

      def grab_page_screenshot_webkit2png(url)
        # generate file names, knowing that webkit2png appends '-full' to the supplied string
        tmp_filename         = new_temporary_image_filename
        screenshot_dir       = File.dirname  tmp_filename
        screenshot_file_base = File.basename tmp_filename, '.png'
    Severity: Minor
    Found in app/workers/refresh_endpoint_worker.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 uniqueness_of_url_and_name_per_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def uniqueness_of_url_and_name_per_user
        unless self.user.nil?
          if self.user.endpoints.where(url: self.url).exists?
            errors.add(:url, "must be unique")
          end
    Severity: Minor
    Found in app/models/endpoint.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