Chocobozzz/PeerTube

View on GitHub
packages/server-commands/src/users/users-command.ts

Summary

Maintainability
F
3 days
Test Coverage

File users-command.ts has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { omit, pick } from '@peertube/peertube-core-utils'
import {
  HttpStatusCode,
  MyUser,
  ResultList,
Severity: Minor
Found in packages/server-commands/src/users/users-command.ts - About 3 hrs to fix

    UsersCommand has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class UsersCommand extends AbstractCommand {
    
      askResetPassword (options: OverrideCommandOptions & {
        email: string
      }) {
    Severity: Minor
    Found in packages/server-commands/src/users/users-command.ts - About 2 hrs to fix

      Function update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        update (options: OverrideCommandOptions & {
          userId: number
          email?: string
          emailVerified?: boolean
          videoQuota?: number
      Severity: Minor
      Found in packages/server-commands/src/users/users-command.ts - 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

        askSendVerifyEmail (options: OverrideCommandOptions & {
          email: string
        }) {
          const { email } = options
          const path = '/api/v1/users/ask-send-verify-email'
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 1 other location - About 2 hrs to fix
      packages/server-commands/src/users/registrations-command.ts on lines 123..137

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

      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

        resetPassword (options: OverrideCommandOptions & {
          userId: number
          verificationString: string
          password: string
        }) {
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 2 other locations - About 2 hrs to fix
      packages/server-commands/src/users/two-factor-command.ts on lines 40..57
      packages/server-commands/src/videos/blacklist-command.ts on lines 6..22

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

      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

        askResetPassword (options: OverrideCommandOptions & {
          email: string
        }) {
          const { email } = options
          const path = '/api/v1/users/ask-reset-password'
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 2 other locations - About 2 hrs to fix
      packages/server-commands/src/custom-pages/custom-pages-command.ts on lines 18..32
      packages/server-commands/src/server/plugins-command.ts on lines 194..208

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

      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

        remove (options: OverrideCommandOptions & {
          userId: number
        }) {
          const { userId } = options
          const path = '/api/v1/users/' + userId
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 3 other locations - About 2 hrs to fix
      packages/server-commands/src/moderation/abuses-command.ts on lines 165..178
      packages/server-commands/src/server/redundancy-command.ts on lines 66..79
      packages/server-commands/src/videos/history-command.ts on lines 24..37

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

      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

        list (options: OverrideCommandOptions & {
          start?: number
          count?: number
          sort?: string
          search?: string
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 1 other location - About 1 hr to fix
      packages/server-commands/src/runners/runner-jobs-command.ts on lines 36..47

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

        getMyScopedTokens (options: OverrideCommandOptions = {}) {
          const path = '/api/v1/users/scoped-tokens'
      
          return this.getRequestBody<ScopedToken>({
            ...options,
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 3 other locations - About 1 hr to fix
      packages/server-commands/src/server/config-command.ts on lines 450..460
      packages/server-commands/src/server/config-command.ts on lines 536..546
      packages/server-commands/src/users/users-command.ts on lines 220..230

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

      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

        getMyInfo (options: OverrideCommandOptions = {}) {
          const path = '/api/v1/users/me'
      
          return this.getRequestBody<MyUser>({
            ...options,
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 3 other locations - About 1 hr to fix
      packages/server-commands/src/server/config-command.ts on lines 450..460
      packages/server-commands/src/server/config-command.ts on lines 536..546
      packages/server-commands/src/users/users-command.ts on lines 131..141

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

      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

        getMyQuotaUsed (options: OverrideCommandOptions = {}) {
          const path = '/api/v1/users/me/video-quota-used'
      
          return this.getRequestBody<UserVideoQuota>({
            ...options,
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 3 other locations - About 1 hr to fix
      packages/server-commands/src/custom-pages/custom-pages-command.ts on lines 6..16
      packages/server-commands/src/moderation/automatic-tags-command.ts on lines 57..67
      packages/server-commands/src/server/debug-command.ts on lines 6..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 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 6 locations. Consider refactoring.
      Open

        deleteMe (options: OverrideCommandOptions = {}) {
          const path = '/api/v1/users/me'
      
          return this.deleteRequest({
            ...options,
      Severity: Major
      Found in packages/server-commands/src/users/users-command.ts and 5 other locations - About 1 hr to fix
      packages/server-commands/src/runners/runner-registration-tokens-command.ts on lines 24..34
      packages/server-commands/src/server/config-command.ts on lines 563..573
      packages/server-commands/src/server/jobs-command.ts on lines 17..27
      packages/server-commands/src/server/jobs-command.ts on lines 29..39
      packages/server-commands/src/server/plugins-command.ts on lines 210..220

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

      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

          return this.getRequestBody<User>({
            ...options,
      
            path,
            query: { withStats },
      Severity: Minor
      Found in packages/server-commands/src/users/users-command.ts and 1 other location - About 50 mins to fix
      packages/server-commands/src/videos/playlists-command.ts on lines 312..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 51.

      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