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 (tags.image?.width && tags.image?.height) {
      metaTags['og:image:width'] = tags.image.width
      metaTags['og:image:height'] = tags.image.height
    }
Severity: Major
Found in server/core/lib/html/shared/tags-html.ts and 1 other location - About 1 hr to fix
server/core/lib/html/shared/tags-html.ts on lines 196..199

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

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 (!options.authName || typeof options.getWeight !== 'function' || typeof options.login !== 'function') {
        logger.error('Cannot register auth plugin %s: authName, getWeight or login are not valid.', this.npmName, { options })
        return
      }
Severity: Major
Found in server/core/lib/plugins/register-helpers.ts and 1 other location - About 1 hr to fix
server/core/lib/plugins/register-helpers.ts on lines 240..243

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

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

function isRunnerJobVideoStudioResultPayloadValid (
  _value: VideoStudioTranscodingSuccess,
  type: RunnerJobType,
  files: UploadFilesForCheck
) {
Severity: Major
Found in server/core/helpers/custom-validators/runners/jobs.ts and 1 other location - About 1 hr to fix
server/core/helpers/custom-validators/runners/jobs.ts on lines 93..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 65.

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

  protected includeStreamingPlaylistRedundancies () {
    this.addJoin(
      'LEFT OUTER JOIN "videoRedundancy" AS "VideoStreamingPlaylists->RedundancyVideos" ' +
        'ON "VideoStreamingPlaylists"."id" = "VideoStreamingPlaylists->RedundancyVideos"."videoStreamingPlaylistId"'
    )
server/core/models/video/sql/video/shared/abstract-video-query-builder.ts on lines 296..307

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

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

  protected includeWebVideoRedundancies () {
    this.addJoin(
      'LEFT OUTER JOIN "videoRedundancy" AS "VideoFiles->RedundancyVideos" ON ' +
        '"VideoFiles"."id" = "VideoFiles->RedundancyVideos"."videoFileId"'
    )
server/core/models/video/sql/video/shared/abstract-video-query-builder.ts on lines 309..320

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

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 (account.Actor.hasImage(ActorImageType.AVATAR)) {
    const avatar = maxBy(account.Actor.Avatars, 'width')
    personImage = WEBSERVER.URL + avatar.getStaticPath()
  }
Severity: Major
Found in server/core/controllers/feeds/video-podcast-feeds.ts and 1 other location - About 1 hr to fix
server/core/controllers/feeds/shared/common-feed-utils.ts on lines 106..109

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

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

async function deleteRemoteFiles () {
  console.log('Detecting remote files that can be deleted...')

  const thumbnails = await ThumbnailModel.listRemoteOnDisk()
  const actorImages = await ActorImageModel.listRemoteOnDisk()
Severity: Minor
Found in server/scripts/house-keeping.ts - About 1 hr to fix

    Function run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function run () {
      await initDatabaseModels(true)
    
      {
        console.log('## Updating "formatFlags" column for web videos in "videoFile" table in database ##\n')
    Severity: Minor
    Found in server/scripts/migrations/peertube-6.3.ts - About 1 hr to fix

      Function listForApi has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static listForApi (options: {
          start: number
          count: number
          videoPlaylistId: number
          serverAccount: AccountModel
      Severity: Minor
      Found in server/core/models/video/video-playlist-element.ts - About 1 hr to fix

        Function listHandlesBlockedBy has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static listHandlesBlockedBy (accountIds: number[]): Promise<string[]> {
            const query = {
              attributes: [ 'id' ],
              where: {
                accountId: {
        Severity: Minor
        Found in server/core/models/account/account-blocklist.ts - About 1 hr to fix

          Function generateSchemaTagsOptions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static generateSchemaTagsOptions (tags: Tags, context: HookContext) {
              if (!tags.schemaType) return
          
              if (tags.schemaType === 'ProfilePage') {
                if (!tags.jsonldProfile) throw new Error('Missing `jsonldProfile` with ProfilePage schema type')
          Severity: Minor
          Found in server/core/lib/html/shared/tags-html.ts - About 1 hr to fix

            Function onVideoStudioEnded has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function onVideoStudioEnded (options: {
              editionResultPath: string
              tasks: VideoStudioTaskPayload[]
              video: MVideoFullLight
            }) {
            Severity: Minor
            Found in server/core/lib/video-studio.ts - About 1 hr to fix

              Function processFollow has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function processFollow (byActor: MActorSignature, activityId: string, targetActorURL: string) {
                const { actorFollow, created, targetActor } = await sequelizeTypescript.transaction(async t => {
                  const targetActor = await ActorModel.loadByUrlAndPopulateAccountAndChannel(targetActorURL, t)
              
                  if (!targetActor) throw new Error('Unknown actor')
              Severity: Minor
              Found in server/core/lib/activitypub/process/process-follow.ts - About 1 hr to fix

                Function buildTasks has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private buildTasks () {
                    const tasks: VideoStudioTask[] = []
                    const value = this.form.value
                
                    const cut = value['cut']
                Severity: Minor
                Found in client/src/app/+video-studio/edit/video-studio-edit.component.ts - About 1 hr to fix

                  Function buildMenu has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private buildMenu () {
                      this.menuEntries = [
                        {
                          label: $localize`Channels`,
                          routerLink: '/my-library/video-channels'
                  Severity: Minor
                  Found in client/src/app/+my-library/my-library.component.ts - About 1 hr to fix

                    Function addWatermark has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async addWatermark (options: BaseStudioOptions & {
                        watermarkPath: string
                    
                        videoFilters: {
                          watermarkSizeRatio: number
                    Severity: Minor
                    Found in packages/ffmpeg/src/ffmpeg-edition.ts - About 1 hr to fix

                      Function buildVideoAttributesFromCommander has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function buildVideoAttributesFromCommander (server: PeerTubeServer, options: UploadOptions) {
                        const defaultBooleanAttributes = {
                          nsfw: false,
                          downloadEnabled: true,
                          waitTranscoding: true
                      Severity: Minor
                      Found in apps/peertube-cli/src/peertube-upload.ts - About 1 hr to fix

                        Function onData has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              readable.on('data', async function onData (chunk) {
                                try {
                                  readable.pause()
                        
                                  const byterangeStart = start + chunk.length - 1
                        Severity: Minor
                        Found in packages/server-commands/src/shared/abstract-command.ts - About 1 hr to fix

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

                                {
                                  title: $localize`Exclude`,
                                  children: [
                                    {
                                      value: 'excludeMuted',
                          client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts on lines 54..66
                          client/src/app/+admin/overview/videos/video-admin.service.ts on lines 45..57
                          client/src/app/+admin/overview/videos/video-admin.service.ts on lines 81..93

                          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

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

                              return this.makeAvailableFactory({
                                createMethods: [
                                  {
                                    method: () => makeHLSFileAvailable(playlist, filename, this.buildTMPDestination(filename)),
                                    clean: true
                          Severity: Major
                          Found in server/core/lib/video-path-manager.ts and 1 other location - About 1 hr to fix
                          server/core/lib/video-path-manager.ts on lines 168..176

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language