FrancisCMS/FrancisCMS

View on GitHub

Showing 6 of 165 total issues

Class AttributesBuilder has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AttributesBuilder
      def initialize(webmention, collection)
        @webmention = webmention
        @source = webmention.source
        @collection = collection
Severity: Minor
Found in app/models/francis_cms/webmention_entry.rb - About 2 hrs to fix

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

        def verify
          @agent.user_agent = "#{FrancisCms.configuration.site_url} (http://webmention.org/)"
    
          if target_accepts_webmentions? && source_links_to_target?
            collection = Microformats2.parse(source_page.body)
    Severity: Minor
    Found in app/models/francis_cms/webmention_verification.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 verify has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def verify
          @agent.user_agent = "#{FrancisCms.configuration.site_url} (http://webmention.org/)"
    
          if target_accepts_webmentions? && source_links_to_target?
            collection = Microformats2.parse(source_page.body)
    Severity: Minor
    Found in app/models/francis_cms/webmention_verification.rb - About 1 hr to fix

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

            def publish
              url = @syndicatable.link? ? @syndicatable.url : @canonical_url
      
              if @syndicatable.photo?
                status = @syndicatable.title.truncate(90, omission: '…', separator: ' ')
      Severity: Minor
      Found in app/models/francis_cms/syndications/twitter.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def create
            source = params[:source]
            target = params[:target]
      
            @webmention = Webmention.where(source: source, target: target).first_or_create(source: source, target: target)
      Severity: Minor
      Found in app/controllers/francis_cms/webmentions_controller.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 link_to_openstreetmap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def link_to_openstreetmap(photo, html_options = {})
            link_to %(https://www.openstreetmap.org/#map=15/#{photo.latitude}/#{photo.longitude}), html_options do
              out = ''
      
              out << %(<span class="p-locality">#{photo.city}</span>) if photo.city
      Severity: Minor
      Found in app/helpers/francis_cms/photos_helper.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