Codeminer42/cm42-central

View on GitHub

Showing 331 of 343 total issues

Class IterationService has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class IterationService
  DAYS_IN_WEEK = (1.week / 1.day)
  VELOCITY_ITERATIONS = 3
  STD_DEV_ITERATIONS = 10
  DEFAULT_VELOCITY = 10
Severity: Minor
Found in app/services/iteration_service.rb - About 2 hrs to fix

    Function ProjectBoard has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    export const ProjectBoard = ({
      fetchProjectBoard,
      projectId,
      projectBoard,
      closeHistory,
    Severity: Minor
    Found in app/assets/javascripts/components/projects/ProjectBoard.jsx - 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

    File project.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Cookies from 'js-cookie';
    import StoryCollection from '../collections/story_collection';
    import UserCollection from '../collections/user_collection';
    import Iteration from '../models/iteration';
    import ProjectBoard from '../models/projectBoard';
    Severity: Minor
    Found in app/assets/javascripts/models/project.js - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export const search = async (queryParam, projectId) => {
        const { data } = await httpService.get(
          `/projects/${projectId}/stories?q=${queryParam}`,
          {
            timeout: 1500,
      Severity: Major
      Found in app/assets/javascripts/models/beta/story.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/models/beta/story.js on lines 178..186

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export const getByLabel = async (label, projectId) => {
        const { data } = await httpService.get(
          `/projects/${projectId}/stories?label=${label}`,
          {
            timeout: 1500,
      Severity: Major
      Found in app/assets/javascripts/models/beta/story.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/models/beta/story.js on lines 168..176

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 83.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Perceived complexity for from_csv is too high. [12/8]
      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 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

      Function mergeWithFetchedStories has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const mergeWithFetchedStories = (currentStories, fetchedStories) => {
        if (Object.values(currentStories).length === 0) {
          const firstStoriesById = fetchedStories.stories.allIds.reduce(
            (acc, storyId) => {
              return {
      Severity: Major
      Found in app/assets/javascripts/reducers/stories.js - About 2 hrs to fix

        File ProjectBoard.jsx has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React, { useEffect, useState } from 'react';
        import { connect } from 'react-redux';
        import {
          fetchProjectBoard,
          toggleColumn,
        Severity: Minor
        Found in app/assets/javascripts/components/projects/ProjectBoard.jsx - About 2 hrs to fix

          Method change_archived has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def change_archived(archive = true)
              @project = policy_scope(Project).archived.friendly.find(params[:id]) unless @project
              authorize @project
          
              result = ProjectOperations::Update.call(
          Severity: Minor
          Found in app/controllers/projects_controller.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

          Complex method ProjectsController#change_archived (41.0)
          Open

            def change_archived(archive = true)
              @project = policy_scope(Project).archived.friendly.find(params[:id]) unless @project
              authorize @project
          
              result = ProjectOperations::Update.call(
          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

          File iteration.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import moment from 'moment';
          import { last, isEmpty } from 'underscore';
          import * as Story from './story';
          
          const weeksBetween = (dateA, dateB) =>
          Severity: Minor
          Found in app/assets/javascripts/models/beta/iteration.js - About 2 hrs to fix

            Complex method ProjectsController#import (39.7)
            Open

              def import
                @import_job = session[:import_job]
                return if @import_job.blank?
            
                job_result = Rails.cache.read(@import_job[:id])
            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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const StoryNotes = props => (
              <div className="form-group">
                <label htmlFor="note">{I18n.t('story.notes')}</label>
                <div className="notelist">{renderNotes(props)}</div>
              </div>
            Severity: Major
            Found in app/assets/javascripts/components/story/StoryNotes.jsx and 1 other location - About 1 hr to fix
            app/assets/javascripts/components/story/StoryTasks.jsx on lines 15..20

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const StoryTasks = props => (
              <div className="form-group">
                <label htmlFor="tasks">{I18n.t('story.tasks')}</label>
                <div className="tasklist checkbox">{renderTasks(props)}</div>
              </div>
            Severity: Major
            Found in app/assets/javascripts/components/story/StoryTasks.jsx and 1 other location - About 1 hr to fix
            app/assets/javascripts/components/story/StoryNotes.jsx on lines 14..19

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function sortUpdate has a Cognitive Complexity of 15 (exceeds 5 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

            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

            Cyclomatic complexity for merge_story! is too high. [8/6]
            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 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.

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module Integrations
              module Slack
                class Service
                  def self.send(private_uri, project_channel, bot_username, message)
                    self.new(private_uri, project_channel, bot_username).send(message)
            Severity: Major
            Found in app/services/integrations/slack/service.rb and 1 other location - About 1 hr to fix
            app/services/integrations/mattermost/service.rb on lines 3..31

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 69.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module Integrations
              module Mattermost
                class Service
                  def self.send(private_uri, project_channel, bot_username, message)
                    self.new(private_uri, project_channel, bot_username).send(message)
            Severity: Major
            Found in app/services/integrations/mattermost/service.rb and 1 other location - About 1 hr to fix
            app/services/integrations/slack/service.rb on lines 3..31

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 69.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function initialize has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              initialize: function (options) {
                _.extend(this, _.pick(options, 'isSearchResult'));
            
                _.bindAll(
                  this,
            Severity: Minor
            Found in app/assets/javascripts/views/story_view.jsx - About 1 hr to fix

              Complex method ActivityPresenter#predicate (38.4)
              Open

                def predicate
                  return '' unless action == 'update'
                  changes = subject_changes.keys.reject { |key| IGNORED_FIELDS.include?(key) }.map do |key|
                    case key
                    when 'documents_attributes' then document_changes subject_changes[key]
              Severity: Minor
              Found in app/presenters/activity_presenter.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