Codeminer42/cm42-central

View on GitHub

Showing 331 of 343 total issues

Method has too many lines. [39/25]
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 checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Function panelHeading has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  panelHeading() {
    const { project, joined } = this.props;

    if (joined) {
      return (
Severity: Major
Found in app/assets/javascripts/components/projects/ProjectCard.jsx - About 3 hrs to fix

    Complex method task#first_team (53.5)
    Open

    task first_team: :environment do
      unless Team.count.zero?
        puts 'Warning: only run this task once, it will only run if there is not team in the system yet'
        exit 1
      end
    Severity: Minor
    Found in lib/tasks/first_team.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

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

    const ExpandedStoryOwnedBy = ({ users, story, onEdit, disabled }) => (
      <ExpandedStorySection
        title={I18n.t('activerecord.attributes.story.owned_by')}
      >
        <SelectUser
    app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryRequestedBy.jsx on lines 7..18

    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 102.

    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 ExpandedStoryRequestedBy = ({ users, story, onEdit, disabled }) => (
      <ExpandedStorySection
        title={I18n.t('activerecord.attributes.story.requested_by')}
      >
        <SelectUser
    app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryOwnedBy.jsx on lines 7..18

    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 102.

    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

    Method from_csv_row has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    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 - 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

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

    export const createNote =
      (projectId, storyId, note) =>
      async (dispatch, getState, { Note }) => {
        dispatch(setLoadingStory(storyId));
    
    
    Severity: Major
    Found in app/assets/javascripts/actions/note.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/actions/task.js on lines 22..33

    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 98.

    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 createTask =
      (projectId, storyId, task) =>
      async (dispatch, getState, { Task }) => {
        dispatch(setLoadingStory(storyId));
    
    
    Severity: Major
    Found in app/assets/javascripts/actions/task.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/actions/note.js on lines 29..40

    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 98.

    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

        case actionTypes.ADD_LABEL:
          return {
            ...state,
            [action.from]: normalizeStories(
              denormalizedStories.map(
    Severity: Major
    Found in app/assets/javascripts/reducers/stories.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/reducers/stories.js on lines 261..279

    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 97.

    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

        case actionTypes.DELETE_LABEL:
          return {
            ...state,
            [action.from]: normalizeStories(
              denormalizedStories.map(
    Severity: Major
    Found in app/assets/javascripts/reducers/stories.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/reducers/stories.js on lines 245..260

    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 97.

    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

    Class Story has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Story < ApplicationRecord
      include ActiveModel::Transitions
      extend Enumerize
    
      before_validation :set_position_to_last
    Severity: Minor
    Found in app/models/story.rb - About 2 hrs to fix

      Assignment Branch Condition size for merge_story! is too high. [35.92/25]
      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 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

      Method from_csv has a Cognitive Complexity of 20 (exceeds 5 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 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

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

      export const deleteTask =
        (projectId, storyId, taskId) =>
        async (dispatch, getState, { Task }) => {
          dispatch(setLoadingStory(storyId));
      
      
      Severity: Major
      Found in app/assets/javascripts/actions/task.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/actions/note.js on lines 16..27

      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 94.

      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 deleteNote =
        (projectId, storyId, noteId) =>
        async (dispatch, getState, { Note }) => {
          dispatch(setLoadingStory(storyId));
      
      
      Severity: Major
      Found in app/assets/javascripts/actions/note.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/actions/task.js on lines 35..46

      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 94.

      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

      Class ProjectsController has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class ProjectsController < ApplicationController
        before_action :set_project, only: %i[show edit update destroy import import_upload
                                             reports ownership archive unarchive
                                             change_archived projects_unjoined]
        before_action :prepare_session, only: %i[import import_upload]
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 2 hrs to fix

        Complex method Activity#merge_story! (46.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 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 story.js has 272 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import ActivityCollection from '../collections/activity_collection';
        import NoteCollection from '../collections/note_collection';
        import TaskCollection from '../collections/task_collection';
        import SharedModelMethods from '../mixins/shared_model_methods';
        
        
        Severity: Minor
        Found in app/assets/javascripts/models/story.js - About 2 hrs to fix

          Function projectBoardReducer has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const projectBoardReducer = (state = initialState, action) => {
            switch (action.type) {
              case actionTypes.REQUEST_PROJECT_BOARD:
                return {
                  ...state,
          Severity: Major
          Found in app/assets/javascripts/reducers/projectBoard.js - About 2 hrs to fix

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

            Severity
            Category
            Status
            Source
            Language