Codeminer42/cm42-central

View on GitHub

Showing 331 of 343 total issues

Complex method IterationService#backlog_iterations (38.4)
Open

  def backlog_iterations(velocity_value = velocity)
    velocity_value = 1 if velocity_value < 1
    @backlog_iterations ||= {}
    # mimics the project.js rebuildIteration() function
    @backlog_iterations[velocity_value] ||= begin
Severity: Minor
Found in app/services/iteration_service.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method Activity::fetch_polymorphic (37.7)
Open

  def self.fetch_polymorphic(ids, since)
    stories = where("subject_type in ('Project', 'Story')")
      .includes(:user, :subject)
      .projects(ids)
      .since(since).to_a
Severity: Minor
Found in app/models/activity.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method task#populate_newposition (37.5)
Open

task populate_newposition: :environment do
  puts "RUNNING TASK: populate_newposition\n\n"

  def update_column(stories)
    new_position = 1
Severity: Minor
Found in lib/tasks/populate_newposition.rake by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Cyclomatic complexity for from_csv_row is too high. [7/6]
Open

    def from_csv_row(row)
      # Ensure no email notifications get sent during CSV import
      project = proxy_association.owner.project
      project.suppress_notifications

Severity: Minor
Found in app/models/story.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for backlog_iterations is too high. [26.74/25]
Open

  def backlog_iterations(velocity_value = velocity)
    velocity_value = 1 if velocity_value < 1
    @backlog_iterations ||= {}
    # mimics the project.js rebuildIteration() function
    @backlog_iterations[velocity_value] ||= begin
Severity: Minor
Found in app/services/iteration_service.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Perceived complexity for merge_story! is too high. [9/8]
Open

  def merge_story!(activity)
    return if subject_type != 'Story' # story only
    return if subject_id != activity.subject_id # only merge the exact same story change
    return if updated_at > activity.updated_at # only merge from future changes
    return if activity.subject_changes.blank?
Severity: Minor
Found in app/models/activity.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Complex method IterationService#group_by_developer (36.8)
Open

  def group_by_developer
    @group_by_developer ||= begin
      min_iteration = @accepted_stories.map(&:iteration_number).min
      max_iteration = @accepted_stories.map(&:iteration_number).max
      @accepted_stories.
Severity: Minor
Found in app/services/iteration_service.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Function sortUpdate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  sortUpdate: function (ev, ui) {
    // The target element, i.e. the StoryView.el element
    var target = $(ev.target);

    // Initially, try and get the id's of the previous and / or next stories
Severity: Minor
Found in app/assets/javascripts/views/story_view.jsx - About 1 hr to fix

    Function rebuildIterations has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        rebuildIterations: function () {
          //
          // Done column
          //
          var that = this;
    Severity: Minor
    Found in app/assets/javascripts/models/project.js - About 1 hr to fix

      Complex method TeamsController#create (36.5)
      Open

        def create
          @team = Team.new(allowed_params)
          authorize @team
      
          return unless check_recaptcha
      Severity: Minor
      Found in app/controllers/teams_controller.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method StoriesController#update (35.9)
      Open

        def update
          @story = policy_scope(Story).find(params[:id])
          authorize @story
      
          @story.acting_user = current_user
      Severity: Minor
      Found in app/controllers/stories_controller.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method main#scoped_collection (35.1)
      Open

          def scoped_collection
            if params[:project_id]
              super.includes(:team)
            elsif params[:team_id]
              super.includes(:project)
      Severity: Minor
      Found in app/admin/ownership.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method StoriesController#create (34.7)
      Open

        def create
          update_current_team
      
          @story = policy_scope(Story).build(allowed_params)
          authorize @story
      Severity: Minor
      Found in app/controllers/stories_controller.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Method from_csv has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def from_csv(csv_string)
            # Eager load this so that we don't have to make multiple db calls when
            # searching for users by full name from the CSV.
            users = proxy_association.owner.users
      
      
      Severity: Minor
      Found in app/models/project.rb - About 1 hr to fix

        Complex method TagGroupsController#create (34.3)
        Open

          def create
            @tag_group = current_team.tag_groups.new(allowed_params)
            authorize @tag_group
        
            respond_to do |format|

        Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

        You can read more about ABC metrics or the flog tool

        Function renderCollapsed has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          renderCollapsed: function (isGuest) {
            this.$el.removeClass('editing');
            this.$el.html(this.template({ story: this.model, view: this }));
            this.$el.toggleClass(
              'collapsed-iteration',
        Severity: Minor
        Found in app/assets/javascripts/views/story_view.jsx - About 1 hr to fix

          Complex method ProjectsController#create (33.7)
          Open

            def create
              @project = policy_scope(Project).new(allowed_params)
              authorize @project
              @project.users << current_user
          
          
          Severity: Minor
          Found in app/controllers/projects_controller.rb by flog

          Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

          You can read more about ABC metrics or the flog tool

          Complex method RemoveStoriesFromUserService#call (33.6)
          Open

            def call
              project.stories
                     .where(requested_by_id: user.id)
                     .or(project.stories.where(owned_by_id: user.id))
                     .where.not(state: "accepted").each do |story|

          Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

          You can read more about ABC metrics or the flog tool

          Function groupBySprints has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const groupBySprints = (
            stories = [],
            project,
            initialSprintNumber = 1
          ) => {
          Severity: Minor
          Found in app/assets/javascripts/models/beta/iteration.js - About 1 hr to fix

            Complex method TeamsController#update (33.2)
            Open

              def update
                @team = current_team
                authorize @team
            
                result = TeamOperations::Update.call(
            Severity: Minor
            Found in app/controllers/teams_controller.rb by flog

            Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

            You can read more about ABC metrics or the flog tool

            Severity
            Category
            Status
            Source
            Language