ianheggie/cruisecontrol.rb

View on GitHub
app/models/project.rb

Summary

Maintainability
F
3 days
Test Coverage

Class Project has 79 methods (exceeds 20 allowed). Consider refactoring.
Open

class Project
  attr_reader :name, :plugins, :build_command, :rake_task, :config_tracker, :path, :settings, :config_file_content, :error_message
  attr_accessor :source_control, :scheduler, :use_bundler, :gemfile, :bundler_args

  alias_method :id, :name
Severity: Major
Found in app/models/project.rb - About 1 day to fix

    File project.rb has 514 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Project
      attr_reader :name, :plugins, :build_command, :rake_task, :config_tracker, :path, :settings, :config_file_content, :error_message
      attr_accessor :source_control, :scheduler, :use_bundler, :gemfile, :bundler_args
    
      alias_method :id, :name
    Severity: Major
    Found in app/models/project.rb - About 1 day to fix

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

        def notify(event, *event_parameters)
          unless BuilderPlugin.known_event? event
            raise "You attempted to notify the project of the #{event} event, but the plugin architecture does not understand this event. Add a method to BuilderPlugin, and document it."
          end
      
      
      Severity: Minor
      Found in app/models/project.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 build_if_necessary has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def build_if_necessary
          begin
            if build_necessary?(reasons = [])
              remove_build_requested_flag_file if build_requested?
              return build(source_control.latest_revision, reasons)
      Severity: Minor
      Found in app/models/project.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 notify has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def notify(event, *event_parameters)
          unless BuilderPlugin.known_event? event
            raise "You attempted to notify the project of the #{event} event, but the plugin architecture does not understand this event. Add a method to BuilderPlugin, and document it."
          end
      
      
      Severity: Minor
      Found in app/models/project.rb - About 1 hr to fix

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

          def build_without_serialization(revision, reasons)
            return if revision.nil? # this will only happen in the case that there are no revisions yet
        
            notify(:build_initiated)
            previous_build = last_build
        Severity: Minor
        Found in app/models/project.rb - About 1 hr to fix

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

              def create(project_name, scm, dir=CruiseControl::Configuration.projects_root)
                raise ArgumentError, "Project Name is required" if project_name.blank?
                Project.new(:name => project_name, :scm => scm).tap do |project|
                  raise "Project named #{project.name.inspect} already exists in #{dir}" if Project.all(dir).include?(project)
                  begin
          Severity: Minor
          Found in app/models/project.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 build_without_serialization has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def build_without_serialization(revision, reasons)
              return if revision.nil? # this will only happen in the case that there are no revisions yet
          
              notify(:build_initiated)
              previous_build = last_build
          Severity: Minor
          Found in app/models/project.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 load_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def load_config
              begin
                retried_after_update = false
                begin
                  load_and_remember config_tracker.central_config_file
          Severity: Minor
          Found in app/models/project.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 generate_release_note has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def generate_release_note(from_revision , to_revision , message , email, release_label)
          Severity: Minor
          Found in app/models/project.rb - About 35 mins to fix

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

              def request_build
                if builder_state_and_activity == 'builder_down'
                  BuilderStarter.begin_builder(name)
                  10.times do
                    sleep 1.second.to_i
            Severity: Minor
            Found in app/models/project.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 do_clean_checkout? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def do_clean_checkout?
                case @clean_checkout_when
                when :always then true
                when nil, :never then false
                else
            Severity: Minor
            Found in app/models/project.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

            There are no issues that match your filters.

            Category
            Status