Chocobozzz/PeerTube

View on GitHub
client/src/app/shared/form-validators/user-validators.ts

Summary

Maintainability
D
2 days
Test Coverage

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

export const USER_PASSWORD_OPTIONAL_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [
    Validators.minLength(6),
    Validators.maxLength(255)
  ],
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 8 other locations - About 2 hrs to fix
client/src/app/shared/form-validators/user-validators.ts on lines 128..137
client/src/app/shared/form-validators/user-validators.ts on lines 139..148
client/src/app/shared/form-validators/video-block-validators.ts on lines 4..10
client/src/app/shared/form-validators/video-channel-validators.ts on lines 30..39
client/src/app/shared/form-validators/video-channel-validators.ts on lines 41..50
client/src/app/shared/form-validators/video-playlist-validators.ts on lines 27..36
client/src/app/shared/form-validators/video-validators.ts on lines 65..71
client/src/app/shared/form-validators/video-validators.ts on lines 81..87

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

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

export const USER_BAN_REASON_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [
    Validators.minLength(3),
    Validators.maxLength(250)
  ],
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 8 other locations - About 2 hrs to fix
client/src/app/shared/form-validators/user-validators.ts on lines 86..95
client/src/app/shared/form-validators/user-validators.ts on lines 128..137
client/src/app/shared/form-validators/video-block-validators.ts on lines 4..10
client/src/app/shared/form-validators/video-channel-validators.ts on lines 30..39
client/src/app/shared/form-validators/video-channel-validators.ts on lines 41..50
client/src/app/shared/form-validators/video-playlist-validators.ts on lines 27..36
client/src/app/shared/form-validators/video-validators.ts on lines 65..71
client/src/app/shared/form-validators/video-validators.ts on lines 81..87

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

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

export const USER_DESCRIPTION_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [
    Validators.minLength(3),
    Validators.maxLength(1000)
  ],
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 8 other locations - About 2 hrs to fix
client/src/app/shared/form-validators/user-validators.ts on lines 86..95
client/src/app/shared/form-validators/user-validators.ts on lines 139..148
client/src/app/shared/form-validators/video-block-validators.ts on lines 4..10
client/src/app/shared/form-validators/video-channel-validators.ts on lines 30..39
client/src/app/shared/form-validators/video-channel-validators.ts on lines 41..50
client/src/app/shared/form-validators/video-playlist-validators.ts on lines 27..36
client/src/app/shared/form-validators/video-validators.ts on lines 65..71
client/src/app/shared/form-validators/video-validators.ts on lines 81..87

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

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

export const USER_VIDEO_QUOTA_DAILY_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1) ],
  MESSAGES: {
    required: $localize`Daily upload limit is required.`,
    min: $localize`Daily upload limit must be greater than -1.`
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 4 other locations - About 1 hr to fix
client/src/app/shared/form-validators/custom-config-validators.ts on lines 76..82
client/src/app/shared/form-validators/custom-config-validators.ts on lines 84..90
client/src/app/shared/form-validators/custom-config-validators.ts on lines 92..98
client/src/app/shared/form-validators/user-validators.ts on lines 104..110

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

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

export const USER_VIDEO_QUOTA_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1) ],
  MESSAGES: {
    required: $localize`Video quota is required.`,
    min: $localize`Quota must be greater than -1.`
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 4 other locations - About 1 hr to fix
client/src/app/shared/form-validators/custom-config-validators.ts on lines 76..82
client/src/app/shared/form-validators/custom-config-validators.ts on lines 84..90
client/src/app/shared/form-validators/custom-config-validators.ts on lines 92..98
client/src/app/shared/form-validators/user-validators.ts on lines 111..117

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

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

export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.email ],
  MESSAGES: {
    required: $localize`Email is required.`,
    email: $localize`Email must be valid.`
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 2 other locations - About 1 hr to fix
client/src/app/shared/form-validators/custom-config-validators.ts on lines 52..58
client/src/app/shared/form-validators/instance-validators.ts on lines 4..10

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

  MESSAGES: {
    required: $localize`Username is required.`,
    minlength: $localize`Username must be at least 1 character long.`,
    maxlength: $localize`Username cannot be more than 50 characters long.`,
    pattern: $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 3 other locations - About 1 hr to fix
client/src/app/shared/form-validators/user-validators.ts on lines 28..33
client/src/app/shared/form-validators/video-channel-validators.ts on lines 9..14
client/src/app/shared/form-validators/video-validators.ts on lines 14..19

Duplicated Code

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

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

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

Tuning

This issue has a mass of 62.

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

  MESSAGES: {
    required: $localize`Channel name is required.`,
    minlength: $localize`Channel name must be at least 1 character long.`,
    maxlength: $localize`Channel name cannot be more than 50 characters long.`,
    pattern: $localize`Channel name should be lowercase, and can contain only alphanumeric characters, dots and underscores.`
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 3 other locations - About 1 hr to fix
client/src/app/shared/form-validators/user-validators.ts on lines 13..18
client/src/app/shared/form-validators/video-channel-validators.ts on lines 9..14
client/src/app/shared/form-validators/video-validators.ts on lines 14..19

Duplicated Code

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

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

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

Tuning

This issue has a mass of 62.

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

export const USER_EXISTING_PASSWORD_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [
    Validators.required
  ],
  MESSAGES: {
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 16 other locations - About 40 mins to fix
client/src/app/+signup/+register/shared/register-validators.ts on lines 4..9
client/src/app/shared/form-validators/common-validators.ts on lines 4..9
client/src/app/shared/form-validators/custom-config-validators.ts on lines 4..9
client/src/app/shared/form-validators/custom-config-validators.ts on lines 18..23
client/src/app/shared/form-validators/login-validators.ts on lines 4..11
client/src/app/shared/form-validators/login-validators.ts on lines 13..20
client/src/app/shared/form-validators/reset-password-validators.ts on lines 4..11
client/src/app/shared/form-validators/user-validators.ts on lines 64..71
client/src/app/shared/form-validators/user-validators.ts on lines 119..124
client/src/app/shared/form-validators/video-captions-validators.ts on lines 4..9
client/src/app/shared/form-validators/video-captions-validators.ts on lines 11..16
client/src/app/shared/form-validators/video-captions-validators.ts on lines 18..23
client/src/app/shared/form-validators/video-ownership-change-validators.ts on lines 4..9
client/src/app/shared/form-validators/video-playlist-validators.ts on lines 18..25
client/src/app/shared/form-validators/video-validators.ts on lines 22..27
client/src/app/shared/form-validators/video-validators.ts on lines 58..63

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

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

export const USER_OTP_TOKEN_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [
    Validators.required
  ],
  MESSAGES: {
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 16 other locations - About 40 mins to fix
client/src/app/+signup/+register/shared/register-validators.ts on lines 4..9
client/src/app/shared/form-validators/common-validators.ts on lines 4..9
client/src/app/shared/form-validators/custom-config-validators.ts on lines 4..9
client/src/app/shared/form-validators/custom-config-validators.ts on lines 18..23
client/src/app/shared/form-validators/login-validators.ts on lines 4..11
client/src/app/shared/form-validators/login-validators.ts on lines 13..20
client/src/app/shared/form-validators/reset-password-validators.ts on lines 4..11
client/src/app/shared/form-validators/user-validators.ts on lines 55..62
client/src/app/shared/form-validators/user-validators.ts on lines 119..124
client/src/app/shared/form-validators/video-captions-validators.ts on lines 4..9
client/src/app/shared/form-validators/video-captions-validators.ts on lines 11..16
client/src/app/shared/form-validators/video-captions-validators.ts on lines 18..23
client/src/app/shared/form-validators/video-ownership-change-validators.ts on lines 4..9
client/src/app/shared/form-validators/video-playlist-validators.ts on lines 18..25
client/src/app/shared/form-validators/video-validators.ts on lines 22..27
client/src/app/shared/form-validators/video-validators.ts on lines 58..63

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

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

export const USER_ROLE_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required ],
  MESSAGES: {
    required: $localize`User role is required.`
  }
Severity: Major
Found in client/src/app/shared/form-validators/user-validators.ts and 16 other locations - About 40 mins to fix
client/src/app/+signup/+register/shared/register-validators.ts on lines 4..9
client/src/app/shared/form-validators/common-validators.ts on lines 4..9
client/src/app/shared/form-validators/custom-config-validators.ts on lines 4..9
client/src/app/shared/form-validators/custom-config-validators.ts on lines 18..23
client/src/app/shared/form-validators/login-validators.ts on lines 4..11
client/src/app/shared/form-validators/login-validators.ts on lines 13..20
client/src/app/shared/form-validators/reset-password-validators.ts on lines 4..11
client/src/app/shared/form-validators/user-validators.ts on lines 55..62
client/src/app/shared/form-validators/user-validators.ts on lines 64..71
client/src/app/shared/form-validators/video-captions-validators.ts on lines 4..9
client/src/app/shared/form-validators/video-captions-validators.ts on lines 11..16
client/src/app/shared/form-validators/video-captions-validators.ts on lines 18..23
client/src/app/shared/form-validators/video-ownership-change-validators.ts on lines 4..9
client/src/app/shared/form-validators/video-playlist-validators.ts on lines 18..25
client/src/app/shared/form-validators/video-validators.ts on lines 22..27
client/src/app/shared/form-validators/video-validators.ts on lines 58..63

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

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

There are no issues that match your filters.

Category
Status