Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

export const MAX_INSTANCE_LIVES_VALIDATOR: BuildFormValidator = {
  VALIDATORS: [ Validators.required, Validators.min(-1) ],
  MESSAGES: {
    required: $localize`Max instance lives is required.`,
    min: $localize`Max instance lives must be greater or equal to -1.`
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 92..98
client/src/app/shared/form-validators/user-validators.ts on lines 104..110
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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

      case 'error': {
        if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
          this.alreadyRefreshedToken = true

          return this.refreshTokenAndRetryUpload()
client/src/app/+my-account/my-account-import-export/my-account-import.component.ts on lines 77..86
client/src/app/+videos/+video-edit/video-update.component.ts on lines 340..349

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

      case 'error': {
        if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
          this.alreadyRefreshedToken = true

          return this.refreshTokenAndRetryUpload()
client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts on lines 168..177
client/src/app/+videos/+video-edit/video-update.component.ts on lines 340..349

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

      case 'error': {
        if (!this.alreadyRefreshedToken && state.responseStatus === HttpStatusCode.UNAUTHORIZED_401) {
          this.alreadyRefreshedToken = true

          return this.refreshTokenAndRetryUpload()
client/src/app/+my-account/my-account-import-export/my-account-import.component.ts on lines 77..86
client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts on lines 168..177

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

  list (options: OverrideCommandOptions & {
    videoId: string | number
  }) {
    const path = '/api/v1/videos/' + options.videoId + '/chapters'

Severity: Major
Found in packages/server-commands/src/videos/chapters-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/videos/storyboard-command.ts on lines 6..18

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

  list (options: OverrideCommandOptions & {
    id: number | string
  }) {
    const path = '/api/v1/videos/' + options.id + '/storyboards'

Severity: Major
Found in packages/server-commands/src/videos/storyboard-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/videos/chapters-command.ts on lines 6..18

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

  private async updateCountryDatabase () {
    if (!CONFIG.GEO_IP.COUNTRY.DATABASE_URL) return false

    await this.updateDatabaseFile(CONFIG.GEO_IP.COUNTRY.DATABASE_URL, this.countryDBPath)

Severity: Major
Found in server/core/helpers/geo-ip.ts and 1 other location - About 1 hr to fix
server/core/helpers/geo-ip.ts on lines 82..90

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

  list (options: OverrideCommandOptions & ListRunnerJobsQuery = {}) {
    const path = '/api/v1/runners/jobs'

    return this.getRequestBody<ResultList<RunnerJobAdmin>>({
      ...options,
Severity: Major
Found in packages/server-commands/src/runners/runner-jobs-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/users/users-command.ts on lines 323..340

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

  private async updateCityDatabase () {
    if (!CONFIG.GEO_IP.CITY.DATABASE_URL) return false

    await this.updateDatabaseFile(CONFIG.GEO_IP.CITY.DATABASE_URL, this.cityDBPath)

Severity: Major
Found in server/core/helpers/geo-ip.ts and 1 other location - About 1 hr to fix
server/core/helpers/geo-ip.ts on lines 72..80

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

Function processVideo has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function processVideo (videoId: number) {
  const video = await VideoModel.loadWithFiles(videoId)

  const hls = video.getHLSPlaylist()
  if (video.isLive || !hls || hls.playlistFilename !== 'master.m3u8' || hls.VideoFiles.length === 0) {
Severity: Minor
Found in server/scripts/migrations/peertube-4.0.ts - About 1 hr to fix

    Function isPackageJSONValid has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType_Type) {
      let result = true
      const badFields: string[] = []
    
      if (!isNpmPluginNameValid(packageJSON.name)) {
    Severity: Minor
    Found in server/core/helpers/custom-validators/plugins.ts - About 1 hr to fix

      Function addLocalViewer has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async addLocalViewer (options: {
          video: MVideoImmutable
          currentTime: number
          ip: string
          sessionId: string
      Severity: Minor
      Found in server/core/lib/views/shared/video-viewer-stats.ts - About 1 hr to fix

        Function sendDeleteVideoComment has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function sendDeleteVideoComment (videoComment: MCommentOwnerVideo, transaction: Transaction) {
          logger.info('Creating job to send delete of comment %s.', videoComment.url)
        
          const isVideoOrigin = videoComment.Video.isOwned()
        
        
        Severity: Minor
        Found in server/core/lib/activitypub/send/send-delete.ts - About 1 hr to fix

          Function processVideoStudioEdition has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function processVideoStudioEdition (job: Job) {
            const payload = job.data as VideoStudioEditionPayload
            const lTags = lTagsBase(payload.videoUUID)
          
            logger.info('Process video studio edition of %s in job %s.', payload.videoUUID, job.id, lTags)
          Severity: Minor
          Found in server/core/lib/job-queue/handlers/video-studio-edition.ts - About 1 hr to fix

            Function runStats has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private runStats () {
                this.p2pEngine.on(Events.PieceBytesDownloaded, (method: string, _segment, bytes: number) => {
                  const elem = method === 'p2p' ? this.statsP2PBytes : this.statsHTTPBytes
            
                  elem.pendingDownload.push(bytes)

              Function buildModerationItems has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private buildModerationItems () {
                  const moderationItems: TopMenuDropdownParam = {
                    label: $localize`Moderation`,
                    children: []
                  }
              Severity: Minor
              Found in client/src/app/+admin/admin.component.ts - About 1 hr to fix

                Function runMetricsInterval has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private runMetricsInterval () {
                    if (this.metricsInterval) clearInterval(this.metricsInterval)
                    if (!this.options_.metricsUrl()) return
                
                    this.metricsInterval = setInterval(() => {
                Severity: Minor
                Found in client/src/assets/player/shared/metrics/metrics-plugin.ts - About 1 hr to fix

                  Function content has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const content = () => {
                        const self = this
                        const player = this.player
                  
                        const shortUUID = self.currentLoadOptions.videoShortUUID
                  Severity: Minor
                  Found in client/src/assets/player/peertube-player.ts - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language