Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

    if (this.options.videoAccountOwnerId) {
      this.buildVideoChannelJoin()

      this.replacements.videoAccountOwnerId = this.options.videoAccountOwnerId

server/core/models/video/sql/comment/video-comment-list-query-builder.ts on lines 224..230

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

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

export {
  ffprobePromise,
  getAudioStream,
  getChaptersFromContainer,

Severity: Major
Found in packages/ffmpeg/src/ffprobe.ts and 1 other location - About 1 hr to fix
apps/peertube-cli/src/shared/cli.ts on lines 179..195

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

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 user.isPasswordMatch(req.body.currentPassword) !== true) {
        return res.fail({
          status: HttpStatusCode.UNAUTHORIZED_401,
          message: 'currentPassword is invalid.',
          type: ServerErrorCode.CURRENT_PASSWORD_IS_INVALID
Severity: Major
Found in server/core/middlewares/validators/users/users.ts and 1 other location - About 1 hr to fix
server/core/middlewares/validators/users/users.ts on lines 404..410

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

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 user.isPasswordMatch(req.body.currentPassword) !== true) {
        return res.fail({
          status: HttpStatusCode.FORBIDDEN_403,
          message: 'currentPassword is invalid.',
          type: ServerErrorCode.CURRENT_PASSWORD_IS_INVALID
Severity: Major
Found in server/core/middlewares/validators/users/users.ts and 1 other location - About 1 hr to fix
server/core/middlewares/validators/users/users.ts on lines 269..275

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

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

type CreateOptions = {
  video: MVideo
  isNewVideo: boolean
  resolution: number
  fps: number
server/core/lib/runners/job-handlers/vod-web-video-transcoding-job-handler.ts on lines 17..25

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

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

    return Promise.all([
      AbuseMessageModel.count(getQuery(true)),
      AbuseMessageModel.findAll(getQuery(false))
    ]).then(([ total, data ]) => ({ total, data }))
Severity: Major
Found in server/core/models/abuse/abuse-message.ts and 1 other location - About 1 hr to fix
server/core/models/account/account-blocklist.ts on lines 154..157

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

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 processAcceptActivity (options: APProcessorOptions<ActivityAccept>) {
  const { byActor: targetActor, inboxActor } = options
  if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.')

  return processAccept(inboxActor, targetActor)
Severity: Major
Found in server/core/lib/activitypub/process/process-accept.ts and 1 other location - About 1 hr to fix
server/core/lib/activitypub/process/process-reject.ts on lines 7..12

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

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

type CreateOptions = {
  video: MVideoWithFile
  isNewVideo: boolean
  resolution: number
  fps: number
server/core/lib/runners/job-handlers/vod-audio-merge-transcoding-job-handler.ts on lines 17..25

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

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

    body('tags')
      .optional()
      .customSanitizer(toValueOrNull)
      .custom(areVideoTagsValid)
      .withMessage(
Severity: Major
Found in server/core/middlewares/validators/videos/videos.ts and 1 other location - About 1 hr to fix
server/core/middlewares/validators/watched-words.ts on lines 65..70

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

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

    return Promise.all([
      AccountBlocklistModel.count(getQuery(true)),
      AccountBlocklistModel.findAll(getQuery(false))
    ]).then(([ total, data ]) => ({ total, data }))
Severity: Major
Found in server/core/models/account/account-blocklist.ts and 1 other location - About 1 hr to fix
server/core/models/abuse/abuse-message.ts on lines 83..86

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

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 (this.options.videoChannelOwnerId) {
      this.buildVideoChannelJoin()

      this.replacements.videoChannelOwnerId = this.options.videoChannelOwnerId

server/core/models/video/sql/comment/video-comment-list-query-builder.ts on lines 216..222

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

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

async function generateVideoPodcastFeed (req: express.Request, res: express.Response) {
  const videoChannel = res.locals.videoChannel

  const { name, userName, description, imageUrl, accountImageUrl, email, link, accountLink } = await buildFeedMetadata({ videoChannel })

Severity: Minor
Found in server/core/controllers/feeds/video-podcast-feeds.ts - About 1 hr to fix

    Function onAfterMuxingCleanup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private async onAfterMuxingCleanup (options: {
        videoUUID: string
        liveSession?: MVideoLiveSession
        cleanupNow?: boolean // Default false
      }) {
    Severity: Minor
    Found in server/core/lib/live/live-manager.ts - About 1 hr to fix

      Function getRedisClientOptions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static getRedisClientOptions (name?: string, options: RedisOptions = {}, logOptions = false): RedisOptions {
          const connectionName = [ 'PeerTube', name ].join('')
          const connectTimeout = 20000 // Could be slow since node use sync call to compile PeerTube
      
          if (CONFIG.REDIS.SENTINEL.ENABLED) {
      Severity: Minor
      Found in server/core/lib/redis.ts - About 1 hr to fix

        Function userRateVideo has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export async function userRateVideo (options: {
          rateType: UserVideoRateType
          account: MAccountUrl & MAccountId
          video: MVideoFullLight
        }) {
        Severity: Minor
        Found in server/core/lib/rate.ts - About 1 hr to fix

          Function updateVideoFile has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            updateVideoFile (options: {
              videoFile: VideoFile
              isUserResolutionChange: boolean
            }) {
              this.currentVideoFile = options.videoFile
          Severity: Minor
          Found in client/src/assets/player/shared/web-video/web-video-plugin.ts - About 1 hr to fix

            Function loadMoreVideoChannels has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private loadMoreVideoChannels () {
                if (this.pagesDone.has(this.pagination.currentPage)) return
                this.pagesDone.add(this.pagination.currentPage)
            
                return this.authService.userInformationLoaded

              Function constructor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                constructor (
                  private authHttp: HttpClient,
                  private restExtractor: RestExtractor
                ) {
                  this.videoQuotaOptions = [
              Severity: Minor
              Found in client/src/app/+admin/config/shared/config.service.ts - About 1 hr to fix

                Function updatePluginFields has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private async updatePluginFields () {
                    this.pluginFields = this.pluginService.getRegisteredVideoFormFields(this.type)
                
                    if (this.pluginFields.length === 0) return
                
                
                Severity: Minor
                Found in client/src/app/+videos/+video-edit/shared/video-edit.component.ts - About 1 hr to fix

                  Function parseQueryStringFilter has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    parseQueryStringFilter <T extends QueryStringFilterPrefixes> (q: string, prefixes: T): ParseQueryStringFiltersResult<keyof T> {
                      if (!q) return {}
                  
                      const tokens = this.tokenizeString(q)
                  
                  
                  Severity: Minor
                  Found in client/src/app/core/rest/rest.service.ts - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language