Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

    } else {
      this.getPlaybackRateButton().show()

      this.player.controlBar.getChild('progressControl').show()
      this.player.controlBar.getChild('currentTimeDisplay').show()
Severity: Major
Found in client/src/assets/player/shared/peertube/peertube-plugin.ts and 1 other location - About 5 hrs to fix
client/src/assets/player/shared/peertube/peertube-plugin.ts on lines 541..550

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

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

  private buildIdsListQuery (options: BuildVideosListQueryOptions) {
    this.attributes = options.attributes || [ '"video"."id"' ]

    if (options.group) this.group = options.group
    if (options.having) this.having = options.having
Severity: Major
Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 5 hrs to fix

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

      constructor (
        protected formReactiveService: FormReactiveService,
        protected loadingBar: LoadingBarService,
        protected notifier: Notifier,
        protected authService: AuthService,
    client/src/app/+videos/+video-edit/video-update.component.ts on lines 82..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 149.

    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

      constructor (
        protected formReactiveService: FormReactiveService,
        private route: ActivatedRoute,
        private router: Router,
        private notifier: Notifier,
    Severity: Major
    Found in client/src/app/+videos/+video-edit/video-update.component.ts and 1 other location - About 5 hrs to fix
    client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts on lines 90..108

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

    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

      acceptFollower (followsArg: ActorFollow[] | ActorFollow) {
        const follows = arrayify(followsArg)
    
        return from(follows)
          .pipe(
    client/src/app/shared/shared-instance/instance-follow.service.ts on lines 109..122

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

    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

      rejectFollower (followsArg: ActorFollow[] | ActorFollow) {
        const follows = arrayify(followsArg)
    
        return from(follows)
          .pipe(
    client/src/app/shared/shared-instance/instance-follow.service.ts on lines 94..107

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

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

    async function run () {
      console.log('Preparing server...')
    
      await prepare()
    
    
    Severity: Major
    Found in scripts/benchmark.ts - About 5 hrs to fix

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

      import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
      import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, booleanAttribute } from '@angular/core'
      import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router'
      import {
        AuthService,
      Severity: Minor
      Found in client/src/app/shared/shared-video-miniature/videos-list.component.ts - About 5 hrs to fix

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

          getFollowings (options: OverrideCommandOptions & {
            start?: number
            count?: number
            sort?: string
            search?: string
        Severity: Major
        Found in packages/server-commands/src/server/follows-command.ts and 1 other location - About 5 hrs to fix
        packages/server-commands/src/server/follows-command.ts on lines 8..28

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

        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

          getFollowers (options: OverrideCommandOptions & {
            start?: number
            count?: number
            sort?: string
            search?: string
        Severity: Major
        Found in packages/server-commands/src/server/follows-command.ts and 1 other location - About 5 hrs to fix
        packages/server-commands/src/server/follows-command.ts on lines 30..50

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

        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 checkUserIdRight (userId: number | string, res: express.Response) {
          if (!await checkUserIdExist(userId, res)) return false
        
          const oauthUser = res.locals.oauth.token.User
        
        
        Severity: Major
        Found in server/core/middlewares/validators/users/user-import.ts and 1 other location - About 5 hrs to fix
        server/core/middlewares/validators/users/user-exports.ts on lines 116..130

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

        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 checkUserIdRight (userId: number | string, res: express.Response) {
          if (!await checkUserIdExist(userId, res)) return false
        
          const oauthUser = res.locals.oauth.token.User
        
        
        Severity: Major
        Found in server/core/middlewares/validators/users/user-exports.ts and 1 other location - About 5 hrs to fix
        server/core/middlewares/validators/users/user-import.ts on lines 96..110

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

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

        async function generateNodeinfo (req: express.Request, res: express.Response) {
          const { totalVideos } = await VideoModel.getStats()
          const { totalLocalVideoComments } = await VideoCommentModel.getStats()
          const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
        
        
        Severity: Major
        Found in server/core/controllers/misc.ts - About 5 hrs to fix

          File server.ts has 395 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { randomInt } from '@peertube/peertube-core-utils'
          import { Video, VideoChannel, VideoChannelSync, VideoCreateResult, VideoDetails } from '@peertube/peertube-models'
          import { parallelTests, root } from '@peertube/peertube-node-utils'
          import { ChildProcess, fork } from 'child_process'
          import { copy } from 'fs-extra/esm'
          Severity: Minor
          Found in packages/server-commands/src/server/server.ts - About 5 hrs to fix

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

                if (await isAudioFile(inputPath, probe)) {
                  videoSource.fps = 0
                  videoSource.resolution = VideoResolution.H_NOVIDEO
                  videoSource.width = 0
                  videoSource.height = 0
            Severity: Major
            Found in server/core/lib/video-file.ts and 1 other location - About 5 hrs to fix
            server/core/lib/video-file.ts on lines 64..75

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

            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 (await isAudioFile(path, probe)) {
                videoFile.fps = 0
                videoFile.resolution = VideoResolution.H_NOVIDEO
                videoFile.width = 0
                videoFile.height = 0
            Severity: Major
            Found in server/core/lib/video-file.ts and 1 other location - About 5 hrs to fix
            server/core/lib/video-file.ts on lines 200..211

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

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

            async function run () {
              await initDatabaseModels(true)
            
              const serverAccount = await getServerActor()
            
            
            Severity: Major
            Found in server/scripts/update-host.ts - About 5 hrs to fix

              VideoCommentModel has 40 functions (exceeds 20 allowed). Consider refactoring.
              Open

              @Scopes(() => ({
                [ScopeNames.WITH_ACCOUNT]: {
                  include: [
                    {
                      model: AccountModel
              Severity: Minor
              Found in server/core/models/video/video-comment.ts - About 5 hrs to fix

                PluginManager has 40 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class PluginManager implements ServerHook {
                
                  private static instance: PluginManager
                
                  private registeredPlugins: { [name: string]: RegisteredPlugin } = {}
                Severity: Minor
                Found in server/core/lib/plugins/plugin-manager.ts - About 5 hrs to fix

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

                  async function handleNewWebVideoResolutionJob (job: Job, payload: NewWebVideoResolutionTranscodingPayload, video: MVideoFullLight) {
                    logger.info('Handling Web Video transcoding job for %s.', video.uuid, lTags(video.uuid), { payload })
                  
                    await transcodeNewWebVideoResolution({ video, resolution: payload.resolution, fps: payload.fps, job })
                  
                  
                  Severity: Major
                  Found in server/core/lib/job-queue/handlers/video-transcoding.ts and 1 other location - About 5 hrs to fix
                  server/core/lib/job-queue/handlers/video-transcoding.ts on lines 77..85

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language