comfy/comfortable-mexican-sofa

View on GitHub

Showing 52 of 135 total issues

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

    def import_layout(path, parent)
      identifier = path.split("/").last

      # reading file content in, resulting in a hash
      content_path = File.join(path, "content.html")
Severity: Minor
Found in lib/comfortable_mexican_sofa/seeds/layout/importer.rb - About 1 hr to fix

    Method create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        categories_scope = @site.categories.of_type("Comfy::Cms::File")
    
        if params[:categories]
          ids = categories_scope.where(label: params[:categories]).pluck(:id)
    Severity: Minor
    Found in app/controllers/comfy/admin/cms/files_controller.rb - About 55 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 import_translations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_translations(path, page)
          old_translations = page.translations.pluck(:locale)
          new_translations = []
    
          Dir["#{path}content.*.html"].each do |file_path|
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/seeds/page/importer.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 assert_exception_raised has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def assert_exception_raised(exception_class = nil, error_message = nil)
        exception_raised = nil
        yield
      rescue StandardError => exception_raised
        exception_raised
    Severity: Minor
    Found in test/test_helper.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 find_site has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.find_site(host, path = nil)
        return Comfy::Cms::Site.first if Comfy::Cms::Site.count == 1
        cms_site = nil
    
        public_cms_path = ComfortableMexicanSofa.configuration.public_cms_path
    Severity: Minor
    Found in app/models/comfy/cms/site.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 render_cms_layout has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def render_cms_layout(identifier, options = {}, locals = {}, &block)
        unless (@cms_layout = @cms_site.layouts.find_by_identifier(identifier))
          raise ComfortableMexicanSofa::MissingLayout, identifier
        end
    
    
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/render_methods.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 assign_parent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def assign_parent
        return unless site
        self.parent ||= site.pages.root unless self == site.pages.root || site.pages.count.zero?
      end
    Severity: Minor
    Found in app/models/comfy/cms/page.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 fragments_attributes= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def fragments_attributes=(frag_hashes = [])
        frag_hashes = frag_hashes.values if frag_hashes.is_a?(Hash)
    
        frag_hashes.each do |frag_attrs|
          unless frag_attrs.is_a?(HashWithIndifferentAccess)
    Severity: Minor
    Found in app/models/concerns/comfy/cms/with_fragments.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 import! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def import!
          Dir.glob("#{path}/*.html").each do |path|
            identifier = File.basename(path, ".html")
    
            # reading file content in, resulting in a hash
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/seeds/snippet/importer.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 content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def content(file: self.file, as: self.as, variant_attrs: self.variant_attrs, label: self.label)
          return "" unless file
    
          url_helpers = Rails.application.routes.url_helpers
    
    
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/content/tags/mixins/file_content.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 export! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def export!
          prepare_folder!(path)
    
          site.pages.each do |page|
            page.slug = "index" if page.slug.blank?
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/seeds/page/exporter.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 import_layout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def import_layout(path, parent)
          identifier = path.split("/").last
    
          # reading file content in, resulting in a hash
          content_path = File.join(path, "content.html")
    Severity: Minor
    Found in lib/comfortable_mexican_sofa/seeds/layout/importer.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