Codeminer42/cm42-central

View on GitHub

Showing 331 of 343 total issues

Complex method IterationService#velocity (27.5)
Open

  def velocity(number_of_iterations = VELOCITY_ITERATIONS)
    return DEFAULT_VELOCITY if group_by_all_iterations.size.zero?
    @velocity ||= {}
    @velocity[number_of_iterations] ||= begin
      number_of_iterations = group_by_all_iterations.size if number_of_iterations > group_by_all_iterations.size
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 StoryOperations::Update#call (27.2)
Open

    def call
      ActiveRecord::Base.transaction do
        yield ensure_valid_state
        yield update_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 storiesReducer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const storiesReducer = (state = initialState, action) => {
  const denormalizedStories = denormalizeStories(state[action.from]);

  switch (action.type) {
    case actionTypes.RECEIVE_STORIES: {
Severity: Minor
Found in app/assets/javascripts/reducers/stories.js - 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

Complex method ProjectsController#update (26.4)
Open

  def update
    result = ProjectOperations::Update.call(
      project: @project,
      project_attrs: allowed_params,
      current_user: 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 UsersController#create (25.8)
Open

  def create
    build_user
    if @user.save
      @user.teams << current_team unless @user.teams.include?(current_team)
      flash[:notice] = I18n.t('was added to the team', scope: 'users', email: @user.email)
Severity: Minor
Found in app/controllers/users_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

ExpandedStoryEstimate.propTypes = {
  project: ProjectPropTypes.isRequired,
  story: editingStoryPropTypesShape.isRequired,
  onEdit: PropTypes.func.isRequired,
  disabled: PropTypes.bool.isRequired,
app/assets/javascripts/components/Notifications/Message.jsx on lines 26..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 56.

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

Message.propTypes = {
  type: PropTypes.string,
  className: PropTypes.string,
  message: PropTypes.string.isRequired,
  onRemove: PropTypes.func.isRequired,
Severity: Minor
Found in app/assets/javascripts/components/Notifications/Message.jsx and 1 other location - About 50 mins to fix
app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryEstimate.jsx on lines 40..45

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

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 RegistrationsController#disable_two_factor (25.4)
Open

  def disable_two_factor
    verify_token = Authy::API.verify(id: current_user.authy_id, token: params[:token], force: true)

    if verify_token.ok?
      disable_authy = Authy::API.delete_user(id: current_user.authy_id)

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

  newStory: function () {
    if ($(window).width() <= 992) {
      _.each(this.columns, function (column, columnId) {
        if (columnId !== 'chilly_bin') if (!column.hidden()) column.toggle();
      });
Severity: Minor
Found in app/assets/javascripts/views/project_view.jsx - 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

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

module Integrations
  module Mattermost
    module Helper
      def send_mattermost(integration, message)
        Integrations::Mattermost::Service.send(real_private_uri(integration.data['private_uri']),
Severity: Minor
Found in app/services/integrations/mattermost/helper.rb and 1 other location - About 45 mins to fix
app/services/integrations/slack/helper.rb on lines 3..16

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

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

  remaining: function () {
    return _.select(this.model.search.models, function (story) {
      return story.get('state') !== 'accepted';
    });
  },
Severity: Minor
Found in app/assets/javascripts/views/epic_bar_view.js and 1 other location - About 45 mins to fix
app/assets/javascripts/views/epic_bar_view.js on lines 41..45

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

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

    velocity: function (userVelocity) {
      if (!_.isUndefined(userVelocity)) {
        if (userVelocity < 1) {
          userVelocity = 1;
        }
Severity: Minor
Found in app/assets/javascripts/models/project.js - 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

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

  done: function () {
    return _.select(this.model.search.models, function (story) {
      return story.get('state') === 'accepted';
    });
  },
Severity: Minor
Found in app/assets/javascripts/views/epic_bar_view.js and 1 other location - About 45 mins to fix
app/assets/javascripts/views/epic_bar_view.js on lines 47..51

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

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 Slack
    module Helper
      def send_slack(integration, message)
        Integrations::Slack::Service.send(real_private_uri(integration.data['private_uri']),
Severity: Minor
Found in app/services/integrations/slack/helper.rb and 1 other location - About 45 mins to fix
app/services/integrations/mattermost/helper.rb on lines 3..16

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

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 ProjectsController#import_upload (24.7)
Open

  def import_upload
    if params[:project].blank?
      flash[:alert] = I18n.t('projects.uploads.select_file')
    else
      session[:import_job] = { id: ImportWorker.new_job_id, created_at: Time.current }
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

      _.each(this.columns, function (column, columnId) {
        if (columnId !== 'chilly_bin') if (!column.hidden()) column.toggle();
      });
Severity: Minor
Found in app/assets/javascripts/views/project_view.jsx and 1 other location - About 40 mins to fix
app/assets/javascripts/views/project_view.jsx on lines 182..184

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

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

      _.each(this.columns, function (column, columnId) {
        if (columnId !== 'in_progress') if (!column.hidden()) column.toggle();
      });
Severity: Minor
Found in app/assets/javascripts/views/project_view.jsx and 1 other location - About 40 mins to fix
app/assets/javascripts/views/project_view.jsx on lines 81..83

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

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 ProjectsController#ownership (24.1)
Open

  def ownership
    team = Team.not_archived.friendly.find(params.dig(:project, :slug))
    manager = ProjectOwnership.new(@project, team, current_team, params.dig(:ownership_action))

    if manager.perform
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 Integrations::Discord::Service#send (24.0)
Open

      def send(text)
        if Rails.env.development?
          Rails.logger.debug('NOT SENDING TO OUTSIDE INTEGRATION!')
          Rails.logger.debug("URL: #{@private_uri}")
          Rails.logger.debug("Payload: #{payload(text)}")

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

      {
        description: I18n.t('toggle_column', { column: 'done' }),
        onClick: () => toggleColumn('done'),
        'data-id': 'toggle-done',
        isVisible: visibleColumns.done,
Severity: Minor
Found in app/assets/javascripts/components/projects/SideBar/index.jsx and 2 other locations - About 40 mins to fix
app/assets/javascripts/components/projects/SideBar/index.jsx on lines 16..22
app/assets/javascripts/components/projects/SideBar/index.jsx on lines 23..29

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

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