gitlabhq/gitlabhq

View on GitHub
lib/banzai/filter/abstract_reference_filter.rb

Summary

Maintainability
D
2 days
Test Coverage

Class AbstractReferenceFilter has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AbstractReferenceFilter < ReferenceFilter
      include CrossProjectReference

      # REFERENCE_PLACEHOLDER is used for re-escaping HTML text except found
      # reference (which we replace with placeholder during re-scaping).  The
Severity: Minor
Found in lib/banzai/filter/abstract_reference_filter.rb - About 5 hrs to fix

    Method call has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

          def call
            return doc unless project || group
    
            ref_pattern = object_class.reference_pattern
            link_pattern = object_class.link_reference_pattern
    Severity: Minor
    Found in lib/banzai/filter/abstract_reference_filter.rb - About 4 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

    File abstract_reference_filter.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Banzai
      module Filter
        # Issues, Merge Requests, Snippets, Commits and Commit Ranges share
        # similar functionality in reference filtering.
        class AbstractReferenceFilter < ReferenceFilter
    Severity: Minor
    Found in lib/banzai/filter/abstract_reference_filter.rb - About 3 hrs to fix

      Method object_link_filter has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def object_link_filter(text, pattern, link_content: nil, link_reference: false)
              references_in(text, pattern) do |match, id, project_ref, namespace_ref, matches|
                parent_path = if parent_type == :group
                                full_group_path(namespace_ref)
                              else
      Severity: Minor
      Found in lib/banzai/filter/abstract_reference_filter.rb - About 2 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 object_link_filter has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def object_link_filter(text, pattern, link_content: nil, link_reference: false)
              references_in(text, pattern) do |match, id, project_ref, namespace_ref, matches|
                parent_path = if parent_type == :group
                                full_group_path(namespace_ref)
                              else
      Severity: Minor
      Found in lib/banzai/filter/abstract_reference_filter.rb - About 1 hr to fix

        Method call has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def call
                return doc unless project || group
        
                ref_pattern = object_class.reference_pattern
                link_pattern = object_class.link_reference_pattern
        Severity: Minor
        Found in lib/banzai/filter/abstract_reference_filter.rb - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status