Noosfero/noosfero

View on GitHub
lib/noosfero/plugin.rb

Summary

Maintainability
F
3 days
Test Coverage

Class Plugin has 98 methods (exceeds 20 allowed). Consider refactoring.
Open

class Noosfero::Plugin
  attr_accessor :context

  def initialize(context = nil)
    self.context = context
Severity: Major
Found in lib/noosfero/plugin.rb - About 1 day to fix

    File plugin.rb has 418 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative "plugin/macro"
    require_relative "plugin/hot_spot"
    require_relative "plugin/manager"
    require_relative "plugin/parent_methods"
    require_relative "plugin/settings"
    Severity: Minor
    Found in lib/noosfero/plugin.rb - About 6 hrs to fix

      Method extra_blocks has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def extra_blocks(params = {})
          return [] if self.class.extra_blocks.nil?
      
          blocks = self.class.extra_blocks.map do |block, options|
            type = options[:type]
      Severity: Minor
      Found in lib/noosfero/plugin.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

      Method autocomplete has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def autocomplete(asset, scope, query, paginate_options = { page: 1 }, options = { field: "name" })
      Severity: Minor
      Found in lib/noosfero/plugin.rb - About 35 mins to fix

        Method find_by_contents has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def find_by_contents(asset, scope, query, paginate_options = {}, options = {})
        Severity: Minor
        Found in lib/noosfero/plugin.rb - About 35 mins to fix

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

            def method_missing(method, *args, &block)
              # This is a generic hotspot for all controllers on Noosfero.
              # If any plugin wants to define filters to run on any controller, the name of
              # the hotspot must be in the following form: <underscored_controller_name>_filters.
              # Example: for ProfileController the hotspot is profile_controller_filters
          Severity: Minor
          Found in lib/noosfero/plugin.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 available_plugins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def available_plugins
                unless @available_plugins
                  path = File.join(Rails.root, "{baseplugins,config/plugins}", "*")
                  @available_plugins = Dir.glob(path).select { |i| File.directory?(i) }
                  if (Rails.env.test? || Rails.env.cucumber?) && !@available_plugins.include?(File.join(Rails.root, "config", "plugins", "foo"))
          Severity: Minor
          Found in lib/noosfero/plugin.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

          There are no issues that match your filters.

          Category
          Status