Chocobozzz/PeerTube

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

Summary

Maintainability
D
3 days
Test Coverage

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

import { About, ActorImageType, ActorImageType_Type, CustomConfig, HttpStatusCode, ServerConfig } from '@peertube/peertube-models'
import { DeepPartial } from '@peertube/peertube-typescript-utils'
import merge from 'lodash-es/merge.js'
import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command.js'

Severity: Minor
Found in packages/server-commands/src/server/config-command.ts - About 7 hrs to fix

    ConfigCommand has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class ConfigCommand extends AbstractCommand {
    
      static getConfigResolutions (enabled: boolean, with0p = false) {
        return {
          '0p': enabled && with0p,
    Severity: Minor
    Found in packages/server-commands/src/server/config-command.ts - About 6 hrs to fix

      Function enableTranscoding has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async enableTranscoding (options: {
          webVideo?: boolean
          hls?: boolean
          keepOriginal?: boolean
          splitAudioAndVideo?: boolean
      Severity: Minor
      Found in packages/server-commands/src/server/config-command.ts - About 1 hr to fix

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

          updateCustomConfig (options: OverrideCommandOptions & {
            newCustomConfig: CustomConfig
          }) {
            const path = '/api/v1/config/custom'
        
        
        Severity: Major
        Found in packages/server-commands/src/server/config-command.ts and 3 other locations - About 2 hrs to fix
        packages/server-commands/src/logs/logs-command.ts on lines 6..17
        packages/server-commands/src/server/metrics-command.ts on lines 6..17
        packages/server-commands/src/users/notifications-command.ts on lines 6..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 78.

        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

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

          getCustomConfig (options: OverrideCommandOptions = {}) {
            const path = '/api/v1/config/custom'
        
            return this.getRequestBody<CustomConfig>({
              ...options,
        Severity: Major
        Found in packages/server-commands/src/server/config-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/users/users-command.ts on lines 131..141
        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 6 locations. Consider refactoring.
        Open

          deleteCustomConfig (options: OverrideCommandOptions = {}) {
            const path = '/api/v1/config/custom'
        
            return this.deleteRequest({
              ...options,
        Severity: Major
        Found in packages/server-commands/src/server/config-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/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
        packages/server-commands/src/users/users-command.ts on lines 259..269

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

          private setUserExportEnabled (enabled: boolean) {
            return this.updateExistingConfig({
              newConfig: {
                export: {
                  users: {
        Severity: Major
        Found in packages/server-commands/src/server/config-command.ts and 3 other locations - About 45 mins to fix
        packages/server-commands/src/server/config-command.ts on lines 109..119
        packages/server-commands/src/server/config-command.ts on lines 144..154
        packages/server-commands/src/server/config-command.ts on lines 190..200

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

        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

          private setFileUpdateEnabled (enabled: boolean) {
            return this.updateExistingConfig({
              newConfig: {
                videoFile: {
                  update: {
        Severity: Major
        Found in packages/server-commands/src/server/config-command.ts and 3 other locations - About 45 mins to fix
        packages/server-commands/src/server/config-command.ts on lines 144..154
        packages/server-commands/src/server/config-command.ts on lines 190..200
        packages/server-commands/src/server/config-command.ts on lines 212..222

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 50.

        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

          private setUserImportEnabled (enabled: boolean) {
            return this.updateExistingConfig({
              newConfig: {
                import: {
                  users: {
        Severity: Major
        Found in packages/server-commands/src/server/config-command.ts and 3 other locations - About 45 mins to fix
        packages/server-commands/src/server/config-command.ts on lines 109..119
        packages/server-commands/src/server/config-command.ts on lines 144..154
        packages/server-commands/src/server/config-command.ts on lines 212..222

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 50.

        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

          private setChannelSyncEnabled (enabled: boolean) {
            return this.updateExistingConfig({
              newConfig: {
                import: {
                  videoChannelSynchronization: {
        Severity: Major
        Found in packages/server-commands/src/server/config-command.ts and 3 other locations - About 45 mins to fix
        packages/server-commands/src/server/config-command.ts on lines 109..119
        packages/server-commands/src/server/config-command.ts on lines 190..200
        packages/server-commands/src/server/config-command.ts on lines 212..222

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 50.

        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