Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

const getRegistrationValidator = [
  param('registrationId')
    .custom(isIdValid),

  async (req: express.Request, res: express.Response, next: express.NextFunction) => {
server/core/middlewares/validators/feeds.ts on lines 104..114

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

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 videoFeedsPodcastValidator = [
  query('videoChannelId')
    .custom(isIdValid),

  async (req: express.Request, res: express.Response, next: express.NextFunction) => {
Severity: Major
Found in server/core/middlewares/validators/feeds.ts and 1 other location - About 3 hrs to fix
server/core/middlewares/validators/users/user-registrations.ts on lines 116..126

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

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

Notifier has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class Notifier {

  private readonly notificationModels = {
    newVideoOrLive: [ NewVideoOrLiveForSubscribers ],
    publicationAfterTranscoding: [ OwnedPublicationAfterTranscoding ],
Severity: Minor
Found in server/core/lib/notifier/notifier.ts - About 3 hrs to fix

    VideoListComponent has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'my-video-list',
      templateUrl: './video-list.component.html',
      styleUrls: [ './video-list.component.scss' ],
      standalone: true,
    Severity: Minor
    Found in client/src/app/+admin/overview/videos/video-list.component.ts - About 3 hrs to fix

      SearchComponent has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Component({
        selector: 'my-search',
        styleUrls: [ './search.component.scss' ],
        templateUrl: './search.component.html',
        standalone: true,
      Severity: Minor
      Found in client/src/app/+search/search.component.ts - About 3 hrs to fix

        File video-file.ts has 305 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {
          FFmpegContainer,
          ffprobePromise,
          getVideoStreamDimensionsInfo,
          getVideoStreamFPS,
        Severity: Minor
        Found in server/core/lib/video-file.ts - About 3 hrs to fix

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

          async function deleteRunner (req: express.Request, res: express.Response) {
            const runner = res.locals.runner
          
            await runner.destroy()
          
          
          Severity: Major
          Found in server/core/controllers/api/runners/manage-runners.ts and 1 other location - About 3 hrs to fix
          server/core/controllers/api/runners/manage-runners.ts on lines 84..91

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

          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

          async function unregisterRunner (req: express.Request, res: express.Response) {
            const runner = res.locals.runner
            await runner.destroy()
          
            logger.info('Unregistered runner %s', runner.name, { ...lTags(runner.name) })
          Severity: Major
          Found in server/core/controllers/api/runners/manage-runners.ts and 1 other location - About 3 hrs to fix
          server/core/controllers/api/runners/manage-runners.ts on lines 93..101

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

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

          async function registerOpentelemetryTracing () {
            if (CONFIG.OPEN_TELEMETRY.TRACING.ENABLED !== true) {
              tracer = new TrackerMock()
          
              return
          Severity: Major
          Found in server/core/lib/opentelemetry/tracing.ts - About 3 hrs to fix

            Function buildWhere has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

              private buildWhere () {
                let where: string[] = []
            
                if (this.options.videoId) {
                  this.replacements.videoId = this.options.videoId

            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

            Function getRemoteObjectOrDie has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            function getRemoteObjectOrDie (
              options: CommonProgramOptions,
              settings: Settings,
              netrc: Netrc
            ): { url: string, username: string, password: string } {
            Severity: Minor
            Found in apps/peertube-cli/src/shared/cli.ts - About 3 hrs 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

              private getVideoChannelObs () {
                const params = {
                  search: this.currentSearch,
                  componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildChannelsPerPage() }),
                  advancedSearch: this.advancedSearch
            Severity: Major
            Found in client/src/app/+search/search.component.ts and 1 other location - About 3 hrs to fix
            client/src/app/+search/search.component.ts on lines 335..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 100.

            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

              onBannerDelete () {
                this.instanceService.deleteInstanceBanner()
                  .subscribe({
                    next: () => {
                      this.notifier.success($localize`Banner deleted.`)
            client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.ts on lines 117..128

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

            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 getVideoPlaylistObs () {
                const params = {
                  search: this.currentSearch,
                  componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildPlaylistsPerPage() }),
                  advancedSearch: this.advancedSearch
            Severity: Major
            Found in client/src/app/+search/search.component.ts and 1 other location - About 3 hrs to fix
            client/src/app/+search/search.component.ts on lines 319..333

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

            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

              onAvatarDelete () {
                this.instanceService.deleteInstanceAvatar()
                  .subscribe({
                    next: () => {
                      this.notifier.success($localize`Avatar deleted.`)
            client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.ts on lines 91..102

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

            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 video-playlist.service.ts has 302 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import debug from 'debug'
            import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
            import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators'
            import { HttpClient, HttpContext, HttpParams } from '@angular/common/http'
            import { Injectable } from '@angular/core'
            Severity: Minor
            Found in client/src/app/shared/shared-video-playlist/video-playlist.service.ts - About 3 hrs to fix

              Function buildExporters has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private buildExporters (exportModel: MUserExport, user: MUserDefault) {
                  const options = {
                    user,
                    activityPubFilenames: {
                      dislikes: 'dislikes.json',
              Severity: Major
              Found in server/core/lib/user-import-export/user-exporter.ts - About 3 hrs to fix

                Function processFile has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function processFile (downloader: () => Promise<string>, videoImport: MVideoImportDefault, options: ProcessFileOptions) {
                  let tmpVideoPath: string
                  let videoFile: MVideoFile
                
                  try {
                Severity: Major
                Found in server/core/lib/job-queue/handlers/video-import.ts - About 3 hrs to fix

                  Function importObject has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    protected async importObject (videoImportData: SanitizedObject) {
                      const videoFilePath = !videoImportData.isLive
                        ? this.getSafeArchivePathOrThrow(videoImportData.archiveFiles.videoFile)
                        : null
                  
                  
                  Severity: Major
                  Found in server/core/lib/user-import-export/importers/videos-importer.ts - About 3 hrs to fix

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

                    import { NgIf } from '@angular/common'
                    import { HttpErrorResponse } from '@angular/common/http'
                    import { AfterViewInit, Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
                    import { FormsModule, ReactiveFormsModule } from '@angular/forms'
                    import { ActivatedRoute, Router } from '@angular/router'
                      Severity
                      Category
                      Status
                      Source
                      Language