Codeminer42/cm42-central

View on GitHub

Showing 331 of 343 total issues

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

Complex method IterationService#backlog_date (32.8)
Open

  def backlog_date(calculate_worst = false)
    iterations            = backlog_iterations(velocity)
    last_iteration_number = iterations.last.number
    if calculate_worst
      std_dev                     = Statistics.standard_deviation(group_by_velocity.values, STD_DEV_ITERATIONS)
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 Story::has_many#from_csv_row (32.7)
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 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 3 locations. Consider refactoring.
Open

    case actionTypes.ADD_NOTE:
      return {
        ...state,
        [action.from]: normalizeStories(
          denormalizedStories.map(
Severity: Major
Found in app/assets/javascripts/reducers/stories.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/reducers/stories.js on lines 173..183
app/assets/javascripts/reducers/stories.js on lines 234..244

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

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 3 locations. Consider refactoring.
Open

    case actionTypes.DELETE_NOTE:
      return {
        ...state,
        [action.from]: normalizeStories(
          denormalizedStories.map(
Severity: Major
Found in app/assets/javascripts/reducers/stories.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/reducers/stories.js on lines 173..183
app/assets/javascripts/reducers/stories.js on lines 212..222

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

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 3 locations. Consider refactoring.
Open

    case actionTypes.ADD_TASK:
      return {
        ...state,
        [action.from]: normalizeStories(
          denormalizedStories.map(
Severity: Major
Found in app/assets/javascripts/reducers/stories.js and 2 other locations - About 1 hr to fix
app/assets/javascripts/reducers/stories.js on lines 212..222
app/assets/javascripts/reducers/stories.js on lines 234..244

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

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

Complex method sidebar#Team Details (32.1)
Open

  sidebar 'Team Details', only: %i[show edit] do
    ul do
      li link_to 'Memberships', manage_user_memberships_path(resource)
      li link_to 'Enrollments', manage_user_enrollments_path(resource)
Severity: Minor
Found in app/admin/user.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 render has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    return (
      <Fragment>
        <div className="search-projects">
          <div className="form-group col-md-12">
Severity: Minor
Found in app/assets/javascripts/components/projects/ProjectSearch.jsx - About 1 hr to fix

    Function renderReleaseStory has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      renderReleaseStory: function () {
        this.$el.append(this.makeFormControl(this.makeTitle()));
    
        if (this.model.get('editing')) {
          this.$el.append(
    Severity: Minor
    Found in app/assets/javascripts/views/story_view.jsx - About 1 hr to fix

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

        appendTags: function () {
          this.$el.append(
            this.makeFormControl(function (div) {
              const $storyTags = $('<div class="form-group" data-tags></div>');
              $(div).append($storyTags);
      Severity: Major
      Found in app/assets/javascripts/views/story_view.jsx and 1 other location - About 1 hr to fix
      app/assets/javascripts/views/story_view.jsx on lines 536..543

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

      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

        appendDescription: function () {
          this.$el.append(
            this.makeFormControl(function (div) {
              var $storyDescription = $('<div class="story-description"><div>');
              $(div).append($storyDescription);
      Severity: Major
      Found in app/assets/javascripts/views/story_view.jsx and 1 other location - About 1 hr to fix
      app/assets/javascripts/views/story_view.jsx on lines 527..534

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

      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

            noteTextArea.keyup(function () {
              if ($.trim(noteTextArea.val())) {
                addNoteButton.removeAttr('disabled');
              } else {
                addNoteButton.attr('disabled', 'disabled');
      Severity: Major
      Found in app/assets/javascripts/views/story_view.jsx and 1 other location - About 1 hr to fix
      app/assets/javascripts/views/story_view.jsx on lines 909..915

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

      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 dragStory has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export const dragStory = (source, destination, backlogSprints, callback) => {
        if (source && destination) {
          const destinationDroppableId = JSON.parse(destination.droppableId);
          const sourceDroppableId = JSON.parse(source.droppableId);
      
      
      Severity: Minor
      Found in app/assets/javascripts/models/beta/projectBoard.js - 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

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

            taskTextArea.keyup(function () {
              if ($.trim(taskTextArea.val())) {
                addTaskButton.removeAttr('disabled');
              } else {
                addTaskButton.attr('disabled', 'disabled');
      Severity: Major
      Found in app/assets/javascripts/views/story_view.jsx and 1 other location - About 1 hr to fix
      app/assets/javascripts/views/story_view.jsx on lines 847..853

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

      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 prepareColumns has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        prepareColumns: function () {
          // reset columns & columns toggle
          this.columns = {};
          this.$columnToggles.html('');
          this.$el.html(
      Severity: Minor
      Found in app/assets/javascripts/views/project_view.jsx - About 1 hr to fix

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

        SideBar.propTypes = {
          reverse: PropTypes.bool.isRequired,
          visibleColumns: PropTypes.object.isRequired,
          toggleColumn: PropTypes.func.isRequired,
          reverseColumns: PropTypes.func.isRequired,
        app/assets/javascripts/components/projects/SideBar/SideBarButton.jsx on lines 29..34
        app/assets/javascripts/components/stories/History/HistoryItem.jsx on lines 18..23
        app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryDescription/ExpandedStoryDescriptionTextArea.jsx on lines 44..49

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

        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 4 locations. Consider refactoring.
        Open

        HistoryItem.propTypes = {
          title: PropTypes.string.isRequired,
          date: PropTypes.string.isRequired,
          user: PropTypes.string.isRequired,
          changes: PropTypes.array.isRequired,
        app/assets/javascripts/components/projects/SideBar/SideBarButton.jsx on lines 29..34
        app/assets/javascripts/components/projects/SideBar/index.jsx on lines 64..69
        app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryDescription/ExpandedStoryDescriptionTextArea.jsx on lines 44..49

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

        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 getColumns has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          (column, stories, project, pastIterations) => {
            switch (column) {
              case Column.CHILLY_BIN:
                return storiesWithScope(stories)
                  .filter(Column.isChillyBin)
        Severity: Minor
        Found in app/assets/javascripts/selectors/columns.js - About 1 hr to fix

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

          SideBarButton.propTypes = {
            children: PropTypes.node.isRequired,
            description: PropTypes.string.isRequired,
            onClick: PropTypes.func.isRequired,
            isVisible: PropTypes.bool.isRequired,
          app/assets/javascripts/components/projects/SideBar/index.jsx on lines 64..69
          app/assets/javascripts/components/stories/History/HistoryItem.jsx on lines 18..23
          app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryDescription/ExpandedStoryDescriptionTextArea.jsx on lines 44..49

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

          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 4 locations. Consider refactoring.
          Open

          ExpandedStoryDescriptionTextArea.propTypes = {
            onEdit: PropTypes.func.isRequired,
            disabled: PropTypes.bool.isRequired,
            users: PropTypes.array.isRequired,
            description: PropTypes.string.isRequired,
          app/assets/javascripts/components/projects/SideBar/SideBarButton.jsx on lines 29..34
          app/assets/javascripts/components/projects/SideBar/index.jsx on lines 64..69
          app/assets/javascripts/components/stories/History/HistoryItem.jsx on lines 18..23

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

          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

          Severity
          Category
          Status
          Source
          Language