discourse/discourse

View on GitHub

Showing 1,401 of 1,401 total issues

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

  def log_check_email(user, opts = {})
    raise Discourse::InvalidParameters.new(:user) unless user
    UserHistory.create(params(opts).merge(action: UserHistory.actions[:check_email],
                                          target_user_id: user.id))
Severity: Major
Found in app/services/staff_action_logger.rb and 8 other locations - About 15 mins to fix
app/services/staff_action_logger.rb on lines 185..188
app/services/staff_action_logger.rb on lines 217..220
app/services/staff_action_logger.rb on lines 292..295
app/services/staff_action_logger.rb on lines 298..301
app/services/staff_action_logger.rb on lines 304..307
app/services/staff_action_logger.rb on lines 310..313
app/services/staff_action_logger.rb on lines 316..319
app/services/staff_action_logger.rb on lines 361..364

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

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

  smj: { i18n: { plural: { keys: [:one, :two, :other], rule: lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } } },
Severity: Major
Found in config/locales/plurals.rb and 7 other locations - About 15 mins to fix
config/locales/plurals.rb on lines 34..34
config/locales/plurals.rb on lines 62..62
config/locales/plurals.rb on lines 84..84
config/locales/plurals.rb on lines 88..88
config/locales/plurals.rb on lines 89..89
config/locales/plurals.rb on lines 91..91
config/locales/plurals.rb on lines 92..92

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

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

      it "should ensure that max settings is smaller or equal to the number of options" do
        raw = <<~RAW
        [poll type=multiple max=3]
        * 1
        * 2
Severity: Minor
Found in plugins/poll/spec/lib/polls_validator_spec.rb and 5 other locations - About 15 mins to fix
plugins/poll/spec/lib/polls_validator_spec.rb on lines 165..176
plugins/poll/spec/lib/polls_validator_spec.rb on lines 195..206
plugins/poll/spec/lib/polls_validator_spec.rb on lines 210..221
plugins/poll/spec/lib/polls_validator_spec.rb on lines 225..236
plugins/poll/spec/lib/polls_validator_spec.rb on lines 240..251

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

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

      it "should ensure that min settings is not greater than the number of options" do
        raw = <<~RAW
        [poll type=multiple min=3]
        * 1
        * 2
Severity: Minor
Found in plugins/poll/spec/lib/polls_validator_spec.rb and 5 other locations - About 15 mins to fix
plugins/poll/spec/lib/polls_validator_spec.rb on lines 165..176
plugins/poll/spec/lib/polls_validator_spec.rb on lines 180..191
plugins/poll/spec/lib/polls_validator_spec.rb on lines 195..206
plugins/poll/spec/lib/polls_validator_spec.rb on lines 210..221
plugins/poll/spec/lib/polls_validator_spec.rb on lines 225..236

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

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

  sms: { i18n: { plural: { keys: [:one, :two, :other], rule: lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } } },
Severity: Major
Found in config/locales/plurals.rb and 7 other locations - About 15 mins to fix
config/locales/plurals.rb on lines 34..34
config/locales/plurals.rb on lines 62..62
config/locales/plurals.rb on lines 84..84
config/locales/plurals.rb on lines 88..88
config/locales/plurals.rb on lines 89..89
config/locales/plurals.rb on lines 90..90
config/locales/plurals.rb on lines 91..91

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

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

  def log_user_unsuspend(user, opts = {})
    raise Discourse::InvalidParameters.new(:user) unless user
    UserHistory.create(params(opts).merge(action: UserHistory.actions[:unsuspend_user],
                                          target_user_id: user.id))
Severity: Major
Found in app/services/staff_action_logger.rb and 8 other locations - About 15 mins to fix
app/services/staff_action_logger.rb on lines 205..208
app/services/staff_action_logger.rb on lines 217..220
app/services/staff_action_logger.rb on lines 292..295
app/services/staff_action_logger.rb on lines 298..301
app/services/staff_action_logger.rb on lines 304..307
app/services/staff_action_logger.rb on lines 310..313
app/services/staff_action_logger.rb on lines 316..319
app/services/staff_action_logger.rb on lines 361..364

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

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

  ga: { i18n: { plural: { keys: [:one, :two, :other], rule: lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } } },
Severity: Major
Found in config/locales/plurals.rb and 7 other locations - About 15 mins to fix
config/locales/plurals.rb on lines 62..62
config/locales/plurals.rb on lines 84..84
config/locales/plurals.rb on lines 88..88
config/locales/plurals.rb on lines 89..89
config/locales/plurals.rb on lines 90..90
config/locales/plurals.rb on lines 91..91
config/locales/plurals.rb on lines 92..92

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

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

    create_table :category_groups, force: true do |t|
      t.integer :category_id, null: false
      t.integer :group_id, null: false
      t.timestamps null: false
    end
Severity: Minor
Found in db/migrate/20130429000101_add_security_to_categories.rb and 4 other locations - About 15 mins to fix
db/migrate/20130416004933_group_users.rb on lines 3..7
db/migrate/20150323234856_add_muted_users.rb on lines 3..7
db/migrate/20150727193414_create_user_field_options.rb on lines 3..7
db/migrate/20150818190757_create_embeddable_hosts.rb on lines 3..7

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

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

      it "should ensure that min settings is not negative" do
        raw = <<~RAW
        [poll type=multiple min=-1]
        * 1
        * 2
Severity: Minor
Found in plugins/poll/spec/lib/polls_validator_spec.rb and 5 other locations - About 15 mins to fix
plugins/poll/spec/lib/polls_validator_spec.rb on lines 165..176
plugins/poll/spec/lib/polls_validator_spec.rb on lines 180..191
plugins/poll/spec/lib/polls_validator_spec.rb on lines 210..221
plugins/poll/spec/lib/polls_validator_spec.rb on lines 225..236
plugins/poll/spec/lib/polls_validator_spec.rb on lines 240..251

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

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

      it "should ensure that min settings it not equal to zero" do
        raw = <<~RAW
        [poll type=multiple min=0]
        * 1
        * 2
Severity: Minor
Found in plugins/poll/spec/lib/polls_validator_spec.rb and 5 other locations - About 15 mins to fix
plugins/poll/spec/lib/polls_validator_spec.rb on lines 165..176
plugins/poll/spec/lib/polls_validator_spec.rb on lines 180..191
plugins/poll/spec/lib/polls_validator_spec.rb on lines 195..206
plugins/poll/spec/lib/polls_validator_spec.rb on lines 225..236
plugins/poll/spec/lib/polls_validator_spec.rb on lines 240..251

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

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

  se: { i18n: { plural: { keys: [:one, :two, :other], rule: lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } } },
Severity: Major
Found in config/locales/plurals.rb and 7 other locations - About 15 mins to fix
config/locales/plurals.rb on lines 34..34
config/locales/plurals.rb on lines 62..62
config/locales/plurals.rb on lines 88..88
config/locales/plurals.rb on lines 89..89
config/locales/plurals.rb on lines 90..90
config/locales/plurals.rb on lines 91..91
config/locales/plurals.rb on lines 92..92

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

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

  sma: { i18n: { plural: { keys: [:one, :two, :other], rule: lambda { |n| n == 1 ? :one : n == 2 ? :two : :other } } } },
Severity: Major
Found in config/locales/plurals.rb and 7 other locations - About 15 mins to fix
config/locales/plurals.rb on lines 34..34
config/locales/plurals.rb on lines 62..62
config/locales/plurals.rb on lines 84..84
config/locales/plurals.rb on lines 89..89
config/locales/plurals.rb on lines 90..90
config/locales/plurals.rb on lines 91..91
config/locales/plurals.rb on lines 92..92

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

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

    create_table :embeddable_hosts, force: true do |t|
      t.string :host, null: false
      t.integer :category_id, null: false
      t.timestamps null: false
    end
Severity: Minor
Found in db/migrate/20150818190757_create_embeddable_hosts.rb and 4 other locations - About 15 mins to fix
db/migrate/20130416004933_group_users.rb on lines 3..7
db/migrate/20130429000101_add_security_to_categories.rb on lines 5..9
db/migrate/20150323234856_add_muted_users.rb on lines 3..7
db/migrate/20150727193414_create_user_field_options.rb on lines 3..7

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

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

      it "should ensure that min settings is not equal to the number of options" do
        raw = <<~RAW
        [poll type=multiple min=2]
        * 1
        * 2
Severity: Minor
Found in plugins/poll/spec/lib/polls_validator_spec.rb and 5 other locations - About 15 mins to fix
plugins/poll/spec/lib/polls_validator_spec.rb on lines 165..176
plugins/poll/spec/lib/polls_validator_spec.rb on lines 180..191
plugins/poll/spec/lib/polls_validator_spec.rb on lines 195..206
plugins/poll/spec/lib/polls_validator_spec.rb on lines 210..221
plugins/poll/spec/lib/polls_validator_spec.rb on lines 240..251

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

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

  def log_grant_admin(user, opts = {})
    raise Discourse::InvalidParameters.new(:user) unless user
    UserHistory.create(params(opts).merge(action: UserHistory.actions[:grant_admin],
                                          target_user_id: user.id))
Severity: Major
Found in app/services/staff_action_logger.rb and 8 other locations - About 15 mins to fix
app/services/staff_action_logger.rb on lines 185..188
app/services/staff_action_logger.rb on lines 205..208
app/services/staff_action_logger.rb on lines 217..220
app/services/staff_action_logger.rb on lines 292..295
app/services/staff_action_logger.rb on lines 304..307
app/services/staff_action_logger.rb on lines 310..313
app/services/staff_action_logger.rb on lines 316..319
app/services/staff_action_logger.rb on lines 361..364

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

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

  def log_grant_moderation(user, opts = {})
    raise Discourse::InvalidParameters.new(:user) unless user
    UserHistory.create(params(opts).merge(action: UserHistory.actions[:grant_moderation],
                                          target_user_id: user.id))
Severity: Major
Found in app/services/staff_action_logger.rb and 8 other locations - About 15 mins to fix
app/services/staff_action_logger.rb on lines 185..188
app/services/staff_action_logger.rb on lines 205..208
app/services/staff_action_logger.rb on lines 217..220
app/services/staff_action_logger.rb on lines 292..295
app/services/staff_action_logger.rb on lines 298..301
app/services/staff_action_logger.rb on lines 304..307
app/services/staff_action_logger.rb on lines 316..319
app/services/staff_action_logger.rb on lines 361..364

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

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

  def log_revoke_admin(user, opts = {})
    raise Discourse::InvalidParameters.new(:user) unless user
    UserHistory.create(params(opts).merge(action: UserHistory.actions[:revoke_admin],
                                          target_user_id: user.id))
Severity: Major
Found in app/services/staff_action_logger.rb and 8 other locations - About 15 mins to fix
app/services/staff_action_logger.rb on lines 185..188
app/services/staff_action_logger.rb on lines 205..208
app/services/staff_action_logger.rb on lines 217..220
app/services/staff_action_logger.rb on lines 292..295
app/services/staff_action_logger.rb on lines 298..301
app/services/staff_action_logger.rb on lines 310..313
app/services/staff_action_logger.rb on lines 316..319
app/services/staff_action_logger.rb on lines 361..364

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

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

  def log_wizard_step(step, opts = {})
    raise Discourse::InvalidParameters.new(:step) unless step
    UserHistory.create(params(opts).merge(action: UserHistory.actions[:wizard_step],
                                          context: step.id))
Severity: Major
Found in app/services/staff_action_logger.rb and 8 other locations - About 15 mins to fix
app/services/staff_action_logger.rb on lines 185..188
app/services/staff_action_logger.rb on lines 205..208
app/services/staff_action_logger.rb on lines 217..220
app/services/staff_action_logger.rb on lines 292..295
app/services/staff_action_logger.rb on lines 298..301
app/services/staff_action_logger.rb on lines 304..307
app/services/staff_action_logger.rb on lines 310..313
app/services/staff_action_logger.rb on lines 316..319

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

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

    create_table :user_field_options, force: true do |t|
      t.references :user_field, null: false
      t.string :value, null: false
      t.timestamps null: false
    end
Severity: Minor
Found in db/migrate/20150727193414_create_user_field_options.rb and 4 other locations - About 15 mins to fix
db/migrate/20130416004933_group_users.rb on lines 3..7
db/migrate/20130429000101_add_security_to_categories.rb on lines 5..9
db/migrate/20150323234856_add_muted_users.rb on lines 3..7
db/migrate/20150818190757_create_embeddable_hosts.rb on lines 3..7

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

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

    create_table :muted_users, force: true do |t|
      t.integer :user_id, null: false
      t.integer :muted_user_id, null: false
      t.timestamps null: false
    end
Severity: Minor
Found in db/migrate/20150323234856_add_muted_users.rb and 4 other locations - About 15 mins to fix
db/migrate/20130416004933_group_users.rb on lines 3..7
db/migrate/20130429000101_add_security_to_categories.rb on lines 5..9
db/migrate/20150727193414_create_user_field_options.rb on lines 3..7
db/migrate/20150818190757_create_embeddable_hosts.rb on lines 3..7

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

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