znamenica/dneslov

View on GitHub
app/lib/tasks.rb

Summary

Maintainability
C
1 day
Test Coverage

Method convert_icon_links_into_images has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def convert_icon_links_into_images
         uri = URI.join(Rails.application.routes.url_helpers.root_url, "/api/v1/images/create.json")

         links = Link.where(type: ["IconLink", "PhotoLink"]).find_each do |l|
            url = Addressable::URI.parse(l.url).normalize.to_s
Severity: Minor
Found in app/lib/tasks.rb - About 3 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

Method convert_icon_links_into_images has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def convert_icon_links_into_images
         uri = URI.join(Rails.application.routes.url_helpers.root_url, "/api/v1/images/create.json")

         links = Link.where(type: ["IconLink", "PhotoLink"]).find_each do |l|
            url = Addressable::URI.parse(l.url).normalize.to_s
Severity: Minor
Found in app/lib/tasks.rb - About 1 hr to fix

    Method fix_links_for_calendary has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

          def fix_links_for_calendary string, slug
             cal = Calendary.by_slug(slug).first
    
             Link.transaction do
                Link.where("url ~* ?", string).where(info_type: "Memory").map do |x|
    Severity: Minor
    Found in app/lib/tasks.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 fix_links_for_calendary has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def fix_links_for_calendary string, slug
             cal = Calendary.by_slug(slug).first
    
             Link.transaction do
                Link.where("url ~* ?", string).where(info_type: "Memory").map do |x|
    Severity: Minor
    Found in app/lib/tasks.rb - About 1 hr to fix

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

            def fix_memo_scripta_for_scripta
               Scriptum.transaction do
                  Scriptum.find_each do |s|
                     begin
                        if s.memo_scripta.blank? && s.service_scripta.present?
      Severity: Minor
      Found in app/lib/tasks.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 fix_root_in_names has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def fix_root_in_names
               Name.all.each do |name|
                  line = [ name ]
                  last = name
      
      
      Severity: Minor
      Found in app/lib/tasks.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

      unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
      Open

                                 x.info.events.where(kind_code: name).first&.memos
      Severity: Minor
      Found in app/lib/tasks.rb by rubocop

      There are no issues that match your filters.

      Category
      Status