Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

import express from 'express'
import { body, param, query, ValidationChain } from 'express-validator'
import { forceNumber } from '@peertube/peertube-core-utils'
import {
  HttpStatusCode,
Severity: Minor
Found in server/core/middlewares/validators/videos/video-playlists.ts - About 3 hrs to fix

    File video-model-builder.ts has 330 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { VideoInclude, VideoIncludeType } from '@peertube/peertube-models'
    import { AccountBlocklistModel } from '@server/models/account/account-blocklist.js'
    import { AccountModel } from '@server/models/account/account.js'
    import { ActorImageModel } from '@server/models/actor/actor-image.js'
    import { ActorModel } from '@server/models/actor/actor.js'
    Severity: Minor
    Found in server/core/models/video/sql/video/shared/video-model-builder.ts - About 3 hrs to fix

      Function buildWhere has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function create has 98 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async create () {
            this.video = new VideoModel(
              await Hooks.wrapObject(this.buildVideo(this.videoAttributes, this.channel), this.videoAttributeResultHook)
            ) as MVideoFullLight
        
        
        Severity: Major
        Found in server/core/lib/local-video-creator.ts - About 3 hrs to fix

          Function buildVideosFromRows has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

            buildVideosFromRows (options: {
              rows: SQLRow[]
              include?: VideoIncludeType
              rowsWebVideoFiles?: SQLRow[]
              rowsStreamingPlaylist?: SQLRow[]
          Severity: Minor
          Found in server/core/models/video/sql/video/shared/video-model-builder.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

          Function fixCompacted has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          function fixCompacted (original: any, compacted: any) {
            if (!original || !compacted) return
          
            for (const [ k, v ] of Object.entries(original)) {
              if (k === '@context' || k === 'signature') continue
          Severity: Minor
          Found in server/core/helpers/peertube-jsonld.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

          Function buildPeerTubePlayerLoadOptions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

            private buildPeerTubePlayerLoadOptions (options: {
              video: VideoDetails
              liveVideo: LiveVideo
              videoCaptions: VideoCaption[]
              videoChapters: VideoChapter[]
          Severity: Minor
          Found in client/src/app/+videos/+video-watch/video-watch.component.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

          Function waitJobs has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          async function waitJobs (
            serversArg: PeerTubeServer[] | PeerTubeServer,
            options: {
              skipDelayed?: boolean // default false
              runnerJobs?: boolean // default false
          Severity: Minor
          Found in packages/server-commands/src/server/jobs.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 3 locations. Consider refactoring.
          Open

          async function getVideoCaption (req: express.Request, res: express.Response) {
            const result = await VideoCaptionsSimpleFileCache.Instance.getFilePath(req.params.filename)
            if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
          
            return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER })
          Severity: Major
          Found in server/core/controllers/lazy-static.ts and 2 other locations - About 3 hrs to fix
          server/core/controllers/lazy-static.ts on lines 108..113
          server/core/controllers/lazy-static.ts on lines 122..127

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            constructor (
              protected formReactiveService: FormReactiveService,
              protected loadingBar: LoadingBarService,
              protected notifier: Notifier,
              protected authService: AuthService,
          client/src/app/+admin/overview/videos/video-list.component.ts on lines 96..110
          client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts on lines 69..83
          client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts on lines 67..81

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            constructor (
              protected formReactiveService: FormReactiveService,
              protected loadingBar: LoadingBarService,
              protected notifier: Notifier,
              protected authService: AuthService,
          client/src/app/+admin/overview/videos/video-list.component.ts on lines 96..110
          client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts on lines 75..89
          client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts on lines 67..81

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            constructor (
              protected route: ActivatedRoute,
              protected router: Router,
              private confirmService: ConfirmService,
              private auth: AuthService,
          client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts on lines 75..89
          client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts on lines 69..83
          client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts on lines 67..81

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

            constructor (
              protected formReactiveService: FormReactiveService,
              protected loadingBar: LoadingBarService,
              protected notifier: Notifier,
              protected authService: AuthService,
          client/src/app/+admin/overview/videos/video-list.component.ts on lines 96..110
          client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts on lines 75..89
          client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts on lines 69..83

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

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

          async function getTorrent (req: express.Request, res: express.Response) {
            const result = await VideoTorrentsSimpleFileCache.Instance.getFilePath(req.params.filename)
            if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
          
            return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.SERVER })
          Severity: Major
          Found in server/core/controllers/lazy-static.ts and 2 other locations - About 3 hrs to fix
          server/core/controllers/lazy-static.ts on lines 108..113
          server/core/controllers/lazy-static.ts on lines 115..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 113.

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

          async function getStoryboard (req: express.Request, res: express.Response) {
            const result = await VideoStoryboardsSimpleFileCache.Instance.getFilePath(req.params.filename)
            if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
          
            return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER })
          Severity: Major
          Found in server/core/controllers/lazy-static.ts and 2 other locations - About 3 hrs to fix
          server/core/controllers/lazy-static.ts on lines 115..120
          server/core/controllers/lazy-static.ts on lines 122..127

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

          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
            } = {}) {
          packages/server-commands/src/runners/runners-command.ts on lines 16..31

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

          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 (type === ThumbnailType.PREVIEW) {
              const filename = generateImageFilename()
              const basePath = CONFIG.STORAGE.PREVIEWS_DIR
          
              return {
          Severity: Major
          Found in server/core/lib/thumbnail.ts and 1 other location - About 3 hrs to fix
          server/core/lib/thumbnail.ts on lines 283..296

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

          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 (type === ThumbnailType.MINIATURE) {
              const filename = generateImageFilename()
              const basePath = CONFIG.STORAGE.THUMBNAILS_DIR
          
              return {
          Severity: Major
          Found in server/core/lib/thumbnail.ts and 1 other location - About 3 hrs to fix
          server/core/lib/thumbnail.ts on lines 298..311

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

          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
            } = {}) {
          Severity: Major
          Found in packages/server-commands/src/runners/runners-command.ts and 1 other location - About 3 hrs to fix
          packages/server-commands/src/runners/runner-registration-tokens-command.ts on lines 7..22

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

          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

          VideoEditComponent has 31 functions (exceeds 20 allowed). Consider refactoring.
          Open

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