Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

  notifyOnAbuseStateChange (abuse: MAbuseFull): void {
    const models = this.notificationModels.abuseStateChange

    logger.debug('Notify on abuse state change', { abuse: abuse.id, ...lTags() })

Severity: Major
Found in server/core/lib/notifier/notifier.ts and 8 other locations - About 3 hrs to fix
server/core/lib/notifier/notifier.ts on lines 83..90
server/core/lib/notifier/notifier.ts on lines 92..99
server/core/lib/notifier/notifier.ts on lines 101..108
server/core/lib/notifier/notifier.ts on lines 121..128
server/core/lib/notifier/notifier.ts on lines 130..137
server/core/lib/notifier/notifier.ts on lines 166..173
server/core/lib/notifier/notifier.ts on lines 186..193
server/core/lib/notifier/notifier.ts on lines 195..202

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

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

  notifyOnNewComment (comment: MCommentOwnerVideo): void {
    const models = this.notificationModels.newComment

    logger.debug('Notify on new comment', { comment: comment.url, ...lTags() })

Severity: Major
Found in server/core/lib/notifier/notifier.ts and 8 other locations - About 3 hrs to fix
server/core/lib/notifier/notifier.ts on lines 83..90
server/core/lib/notifier/notifier.ts on lines 92..99
server/core/lib/notifier/notifier.ts on lines 101..108
server/core/lib/notifier/notifier.ts on lines 130..137
server/core/lib/notifier/notifier.ts on lines 166..173
server/core/lib/notifier/notifier.ts on lines 186..193
server/core/lib/notifier/notifier.ts on lines 195..202
server/core/lib/notifier/notifier.ts on lines 236..243

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

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

  notifyOnVideoUnblacklist (video: MVideoFullLight): void {
    const models = this.notificationModels.unblacklist

    logger.debug('Notify on video unblacklist', { video: video.url, ...lTags() })

Severity: Major
Found in server/core/lib/notifier/notifier.ts and 8 other locations - About 3 hrs to fix
server/core/lib/notifier/notifier.ts on lines 83..90
server/core/lib/notifier/notifier.ts on lines 92..99
server/core/lib/notifier/notifier.ts on lines 101..108
server/core/lib/notifier/notifier.ts on lines 121..128
server/core/lib/notifier/notifier.ts on lines 130..137
server/core/lib/notifier/notifier.ts on lines 186..193
server/core/lib/notifier/notifier.ts on lines 195..202
server/core/lib/notifier/notifier.ts on lines 236..243

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

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

  notifyOnNewCommentApproval (comment: MCommentOwnerVideo): void {
    const models = this.notificationModels.commentApproval

    logger.debug('Notify on comment approval', { comment: comment.url, ...lTags() })

Severity: Major
Found in server/core/lib/notifier/notifier.ts and 8 other locations - About 3 hrs to fix
server/core/lib/notifier/notifier.ts on lines 83..90
server/core/lib/notifier/notifier.ts on lines 92..99
server/core/lib/notifier/notifier.ts on lines 101..108
server/core/lib/notifier/notifier.ts on lines 121..128
server/core/lib/notifier/notifier.ts on lines 166..173
server/core/lib/notifier/notifier.ts on lines 186..193
server/core/lib/notifier/notifier.ts on lines 195..202
server/core/lib/notifier/notifier.ts on lines 236..243

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

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

  if (
    CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.BUCKET_NAME &&
    CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === CONFIG.OBJECT_STORAGE.STREAMING_PLAYLISTS.PREFIX
  ) {
    if (CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === '') {
Severity: Major
Found in server/core/initializers/checker-after-init.ts and 1 other location - About 3 hrs to fix
server/core/initializers/checker-after-init.ts on lines 333..344

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

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

      {
        title: $localize`Video files`,
        children: [
          {
            value: 'webVideos:true isLocal:true',
Severity: Major
Found in client/src/app/+admin/overview/videos/video-admin.service.ts and 1 other location - About 3 hrs to fix
client/src/app/+admin/system/runners/runner-job-list/runner-job-list.component.ts on lines 48..68

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

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

  {
    const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos()
    const { bodyValidator, deleter, updater } = commentOptionsFactory()

    await Bluebird.map(commentUrls, async commentUrl => {
Severity: Major
Found in server/core/lib/job-queue/handlers/activitypub-cleaner.ts and 1 other location - About 3 hrs to fix
server/core/lib/job-queue/handlers/activitypub-cleaner.ts on lines 46..53

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

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

    if (
      CONFIG.OBJECT_STORAGE.WEB_VIDEOS.BUCKET_NAME === CONFIG.OBJECT_STORAGE.ORIGINAL_VIDEO_FILES.BUCKET_NAME &&
      CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === CONFIG.OBJECT_STORAGE.ORIGINAL_VIDEO_FILES.PREFIX
    ) {
      if (CONFIG.OBJECT_STORAGE.WEB_VIDEOS.PREFIX === '') {
Severity: Major
Found in server/core/initializers/checker-after-init.ts and 1 other location - About 3 hrs to fix
server/core/initializers/checker-after-init.ts on lines 313..324

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

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

  {
    const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos()
    const { bodyValidator, deleter, updater } = shareOptionsFactory()

    await Bluebird.map(shareUrls, async shareUrl => {
Severity: Major
Found in server/core/lib/job-queue/handlers/activitypub-cleaner.ts and 1 other location - About 3 hrs to fix
server/core/lib/job-queue/handlers/activitypub-cleaner.ts on lines 55..62

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

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

    {
      title: $localize`Advanced filters`,
      children: [
        {
          value: 'state:completed',
client/src/app/+admin/overview/videos/video-admin.service.ts on lines 59..79

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

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 up has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
Severity: Major
Found in server/core/initializers/migrations/0595-remote-url.ts - About 3 hrs to fix

    VideoAddToPlaylistComponent has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'my-video-add-to-playlist',
      styleUrls: [ './video-add-to-playlist.component.scss' ],
      templateUrl: './video-add-to-playlist.component.html',
      changeDetection: ChangeDetectionStrategy.OnPush,

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

          this.userAdminService.unbanUsers(user)
              .subscribe({
                next: () => {
                  this.notifier.success($localize`User ${user.username} unbanned.`)
                  this.userChanged.emit()
      client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts on lines 112..120

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

      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

          this.userAdminService.removeUsers(user)
            .subscribe({
              next: () => {
                this.notifier.success($localize`User ${user.username} deleted.`)
                this.userDeleted.emit()
      client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts on lines 90..98

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

      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

          this.userService.updateMyProfile(details)
            .subscribe({
              next: () => {
                this.authService.refreshUserInformation()
      
      
      client/src/app/shared/shared-user-settings/user-interface-settings.component.ts on lines 91..100

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

      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

            this.userService.updateMyProfile(details)
              .subscribe({
                next: () => {
                  this.authService.refreshUserInformation()
      
      
      client/src/app/shared/shared-user-settings/user-video-settings.component.ts on lines 134..143

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

      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

      File local-video-viewer.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { QueryTypes } from 'sequelize'
      import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, HasMany, IsUUID, Table } from 'sequelize-typescript'
      import { getActivityStreamDuration } from '@server/lib/activitypub/activity.js'
      import { buildGroupByAndBoundaries } from '@server/lib/timeserie.js'
      import { MLocalVideoViewer, MLocalVideoViewerWithWatchSections, MVideo } from '@server/types/models/index.js'
      Severity: Minor
      Found in server/core/models/view/local-video-viewer.ts - About 3 hrs to fix

        File thumbnail.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { ThumbnailType, ThumbnailType_Type, VideoFileStream } from '@peertube/peertube-models'
        import { generateThumbnailFromVideo } from '@server/helpers/ffmpeg/ffmpeg-image.js'
        import { logger, loggerTagsFactory } from '@server/helpers/logger.js'
        import Bluebird from 'bluebird'
        import { FfprobeData } from 'fluent-ffmpeg'
        Severity: Minor
        Found in server/core/lib/thumbnail.ts - About 3 hrs to fix

          File user-list.component.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { DatePipe, NgClass, NgIf } from '@angular/common'
          import { Component, OnInit, ViewChild } from '@angular/core'
          import { FormsModule } from '@angular/forms'
          import { ActivatedRoute, Router, RouterLink } from '@angular/router'
          import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable } from '@app/core'
          Severity: Minor
          Found in client/src/app/+admin/overview/users/user-list/user-list.component.ts - About 3 hrs to fix

            File video-update.component.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import debug from 'debug'
            import { UploadState, UploadxService } from 'ngx-uploadx'
            import { of, Subject, Subscription } from 'rxjs'
            import { catchError, map, switchMap } from 'rxjs/operators'
            import { SelectChannelItem } from 'src/types/select-options-item.model'
            Severity: Minor
            Found in client/src/app/+videos/+video-edit/video-update.component.ts - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language