Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

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

    {
      const query = `UPDATE "actorImage" SET "actorId" = (SELECT "id" FROM "actor" WHERE "actor"."bannerId" = "actorImage"."id") ` +
                    `WHERE "type" = 2`
      await utils.sequelize.query(query, { type: Sequelize.QueryTypes.UPDATE, transaction: utils.transaction })
    }
server/core/initializers/migrations/0685-multiple-actor-images.ts on lines 22..26

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

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

  findLiveSessionFromVOD (videoId: number | string) {
    return this.authHttp
               .get<LiveVideoSession>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/live-session')
               .pipe(catchError(err => this.restExtractor.handleError(err)))
  }
client/src/app/+stats/video/video-stats.service.ts on lines 51..54

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

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 unblockServer (req: express.Request, res: express.Response) {
  const serverBlock = res.locals.serverBlock

  await removeServerFromBlocklist(serverBlock)

Severity: Major
Found in server/core/controllers/api/server/server-blocklist.ts and 2 other locations - About 1 hr to fix
server/core/controllers/api/server/server-blocklist.ts on lines 111..117
server/core/controllers/api/users/my-blocklist.ts on lines 138..144

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

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 (resolution.active) {
        const itemEl = document.createElement('strong')
        itemEl.innerText = `${resolution.label} (active)`
        itemEl.style.display = 'block'
        resolutionListEl.appendChild(itemEl)
Severity: Major
Found in client/src/standalone/videos/test-embed.ts and 1 other location - About 1 hr to fix
client/src/standalone/videos/test-embed.ts on lines 105..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 69.

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

  askSendVerifyEmail (email: string) {
    const url = UserService.BASE_USERS_URL + 'ask-send-verify-email'

    return this.authHttp.post(url, { email })
               .pipe(catchError(err => this.restExtractor.handleError(err)))
Severity: Major
Found in client/src/app/+signup/shared/signup.service.ts and 1 other location - About 1 hr to fix
client/src/app/core/users/user.service.ts on lines 139..144

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

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

  askResetPassword (email: string) {
    const url = UserService.BASE_USERS_URL + '/ask-reset-password'

    return this.authHttp.post(url, { email })
               .pipe(catchError(err => this.restExtractor.handleError(err)))
Severity: Major
Found in client/src/app/core/users/user.service.ts and 1 other location - About 1 hr to fix
client/src/app/+signup/shared/signup.service.ts on lines 61..66

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

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

  static loadById (id: number, transaction?: Transaction): Promise<MComment> {
    const query = {
      where: {
        id
      },
Severity: Major
Found in server/core/models/video/video-comment.ts and 1 other location - About 1 hr to fix
server/core/models/server/server.ts on lines 66..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 69.

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 function makePostBodyRequest (options: CommonRequestParams & {
  fields?: { [ fieldName: string ]: any }
}) {
  const req = request(options.url).post(options.path)
                                  .send(options.fields)
Severity: Major
Found in packages/server-commands/src/requests/requests.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/requests/requests.ts on lines 173..185

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

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 (c.mode === 'showing') {
        const itemEl = document.createElement('strong')
        itemEl.innerText = `${c.label} (active)`
        itemEl.style.display = 'block'
        captionEl.appendChild(itemEl)
Severity: Major
Found in client/src/standalone/videos/test-embed.ts and 1 other location - About 1 hr to fix
client/src/standalone/videos/test-embed.ts on lines 131..145

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

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

  static load (id: number, transaction?: Transaction): Promise<MServer> {
    const query = {
      where: {
        id
      },
Severity: Major
Found in server/core/models/server/server.ts and 1 other location - About 1 hr to fix
server/core/models/video/video-comment.ts on lines 237..246

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

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

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
Severity: Minor
Found in server/core/initializers/migrations/0725-node-version.ts - About 1 hr to fix

    Function generateVideoCommentsFeed has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function generateVideoCommentsFeed (req: express.Request, res: express.Response) {
      const start = 0
      const video = res.locals.videoAll
      const account = res.locals.account
      const videoChannel = res.locals.videoChannel
    Severity: Minor
    Found in server/core/controllers/feeds/comment-feeds.ts - About 1 hr to fix

      Function getFiles has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          getFiles: async (id: number | string) => {
            const video = await VideoModel.loadFull(id)
            if (!video) return undefined
      
            const webVideoFiles = (video.VideoFiles || []).map(f => ({
      Severity: Minor
      Found in server/core/lib/plugins/plugin-helpers-builder.ts - About 1 hr to fix

        Function replaceLiveByReplay has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function replaceLiveByReplay (options: {
          video: MVideo
          liveSession: MVideoLiveSession
          live: MVideoLive
          permanentLive: boolean
        Severity: Minor
        Found in server/core/lib/job-queue/handlers/video-live-ending.ts - About 1 hr to fix

          Function addTags has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static async addTags (htmlStringPage: string, tagsValues: Tags, context: HookContext) {
              const openGraphMetaTags = this.generateOpenGraphMetaTagsOptions(tagsValues)
              const standardMetaTags = this.generateStandardMetaTagsOptions(tagsValues)
              const twitterCardMetaTags = this.generateTwitterCardMetaTagsOptions(tagsValues)
              const schemaTags = await this.generateSchemaTagsOptions(tagsValues, context)
          Severity: Minor
          Found in server/core/lib/html/shared/tags-html.ts - About 1 hr to fix

            Function generateHlsPlaylistCommon has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function generateHlsPlaylistCommon (options: {
              type: 'hls' | 'hls-from-ts'
              video: MVideo
            
              videoInputPath: string
            Severity: Minor
            Found in server/core/lib/transcoding/hls-transcoding.ts - About 1 hr to fix

              Function onHLSVideoFileTranscoding has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function onHLSVideoFileTranscoding (options: {
                video: MVideo
                videoOutputPath: string
                m3u8OutputPath: string
                filesLockedInParent?: boolean // default false
              Severity: Minor
              Found in server/core/lib/transcoding/hls-transcoding.ts - About 1 hr to fix

                Function upload has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async upload (options: OverrideCommandOptions & {
                    attributes?: VideoEdit
                    mode?: 'legacy' | 'resumable' // default legacy
                    waitTorrentGeneration?: boolean // default true
                    completedExpectedStatus?: HttpStatusCodeType
                Severity: Minor
                Found in packages/server-commands/src/videos/videos-command.ts - About 1 hr to fix

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

                    constructor (
                      protected formReactiveService: FormReactiveService,
                      private pluginService: PluginService,
                      private pluginAPIService: PluginApiService,
                      private notifier: Notifier,
                  client/src/app/+about/about-instance/contact-admin-modal.component.ts on lines 41..50
                  client/src/app/+manage/video-channel-edit/video-channel-create.component.ts on lines 50..59
                  client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts on lines 31..40
                  client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts on lines 46..55
                  client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal-content.component.ts on lines 82..91
                  client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts on lines 37..46
                  client/src/app/shared/shared-user-settings/user-interface-settings.component.ts on lines 29..38

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

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

                    constructor (
                      protected formReactiveService: FormReactiveService,
                      private authService: AuthService,
                      private notifier: Notifier,
                      private userService: UserService,
                  client/src/app/+about/about-instance/contact-admin-modal.component.ts on lines 41..50
                  client/src/app/+admin/plugins/plugin-show-installed/plugin-show-installed.component.ts on lines 30..39
                  client/src/app/+manage/video-channel-edit/video-channel-create.component.ts on lines 50..59
                  client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts on lines 31..40
                  client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts on lines 46..55
                  client/src/app/+videos/+video-edit/shared/caption/video-caption-edit-modal-content.component.ts on lines 82..91
                  client/src/app/shared/shared-abuse-list/abuse-message-modal.component.ts on lines 37..46

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

                  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