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 body = await unwrapBody<{ videoChannel: VideoChannelCreateResult }>(this.postBodyRequest({
      ...options,

      path,
      fields: attributes,
Severity: Major
Found in packages/server-commands/src/videos/channels-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/videos/playlists-command.ts on lines 234..241

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

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

    muxingSession.on('duration-exceeded', ({ videoUUID }) => {
      logger.info('Stopping session of %s: max duration exceeded.', videoUUID, localLTags)

      this.stopSessionOfVideo({ videoUUID, error: LiveVideoError.DURATION_EXCEEDED })
    })
Severity: Major
Found in server/core/lib/live/live-manager.ts and 1 other location - About 1 hr to fix
server/core/lib/live/live-manager.ts on lines 426..430

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

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

      it('Should accept the registration', async function () {
        await loginPage.loginAsRootUser()

        await adminRegistrationPage.navigateToRegistratonsList()
        await adminRegistrationPage.accept('user_2', 'moderation response')
Severity: Major
Found in client/e2e/src/suites-local/signup.e2e-spec.ts and 1 other location - About 1 hr to fix
client/e2e/src/suites-local/signup.e2e-spec.ts on lines 378..385

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

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

    const body = await unwrapBody<{ videoPlaylistElement: VideoPlaylistElementCreateResult }>(this.postBodyRequest({
      ...options,

      path,
      fields: attributes,
Severity: Major
Found in packages/server-commands/src/videos/playlists-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/videos/channels-command.ts on lines 69..76

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

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 loadByIdAndPopulateVideoAndAccountAndReply (id: number, transaction?: Transaction): Promise<MCommentOwnerVideoReply> {
    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/video/video-comment.ts on lines 263..272

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

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

  toFormattedJSON (): VideoPassword {
    return {
      id: this.id,
      password: this.password,
      videoId: this.videoId,
Severity: Major
Found in server/core/models/video/video-password.ts and 1 other location - About 1 hr to fix
server/core/models/watched-words/watched-words-list.ts on lines 197..205

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

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

  addUser (userCreate: UserCreate) {
    return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
               .pipe(catchError(err => this.restExtractor.handleError(err)))
  }
Severity: Major
Found in client/src/app/shared/shared-users/user-admin.service.ts and 1 other location - About 1 hr to fix
client/src/app/shared/shared-main/channel/video-channel.service.ts on lines 80..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 63.

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 34 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/0660-object-storage.ts - About 1 hr to fix

    Function acceptRunnerJob has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function acceptRunnerJob (req: express.Request, res: express.Response) {
      const runner = res.locals.runner
      const runnerJob = res.locals.runnerJob
    
      const newRunnerJob = await retryTransactionWrapper(() => {
    Severity: Minor
    Found in server/core/controllers/api/runners/jobs.ts - About 1 hr to fix

      Function handleToken has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function handleToken (req: express.Request, res: express.Response, next: express.NextFunction) {
        const grantType = req.body.grant_type
      
        try {
          const bypassLogin = await buildByPassLogin(req, grantType)
      Severity: Minor
      Found in server/core/controllers/api/users/token.ts - About 1 hr to fix

        Function reorderVideosPlaylist has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function reorderVideosPlaylist (req: express.Request, res: express.Response) {
          const videoPlaylist = res.locals.videoPlaylistFull
          const body: VideoPlaylistReorder = req.body
        
          const start: number = body.startPosition
        Severity: Minor
        Found in server/core/controllers/api/video-playlist.ts - About 1 hr to fix

          Function updateObjectIfNeeded has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function updateObjectIfNeeded <T> (options: {
            url: string
            bodyValidator: (body: any) => boolean
            updater: (url: string, newUrl: string) => Promise<T>
            deleter: (url: string) => Promise<T> }
          Severity: Minor
          Found in server/core/lib/job-queue/handlers/activitypub-cleaner.ts - About 1 hr to fix

            Function processVideosViewsStats has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function processVideosViewsStats () {
              const lastHour = new Date()
            
              // In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour
              if (!isTestOrDevInstance()) lastHour.setHours(lastHour.getHours() - 1)
            Severity: Minor
            Found in server/core/lib/job-queue/handlers/video-views-stats.ts - About 1 hr to fix

              Function buildNewFile has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function buildNewFile (options: {
                path: string
                mode: 'web-video' | 'hls'
                ffprobe?: FfprobeData
              }): Promise<MVideoFile> {
              Severity: Minor
              Found in server/core/lib/video-file.ts - About 1 hr to fix

                Function createElements has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private async createElements (playlist: MVideoPlaylistThumbnail, playlistImportData: SanitizedObject) {
                    const elementsToCreate: { videoId: number, startTimestamp: number, stopTimestamp: number }[] = []
                
                    for (const element of playlistImportData.elements.slice(0, USER_IMPORT.MAX_PLAYLIST_ELEMENTS)) {
                      const video = await loadOrCreateVideoIfAllowedForUser(element.videoUrl)

                  Function updateSha256VODSegments has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function updateSha256VODSegments (video: MVideo, playlistArg: MStreamingPlaylist): Promise<MStreamingPlaylistFilesVideo> {
                    return playlistFilesQueue.add(async () => {
                      const json: { [filename: string]: { [range: string]: string } } = {}
                  
                      const playlist = await VideoStreamingPlaylistModel.loadWithVideoAndFiles(playlistArg.id)
                  Severity: Minor
                  Found in server/core/lib/hls.ts - About 1 hr to fix

                    Function validate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async validate (segment: Segment, _method: string, _peerId: string, retry = 1) {
                        if (this.destroyed) return
                    
                        this.loadSha256SegmentsPromiseIfNeeded()
                    
                    

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

                        async create () {
                          logger.debug('Adding remote video %s.', this.videoObject.id, this.lTags())
                      
                          const channelActor = await this.getOrCreateVideoChannelFromVideoObject()
                          const channel = channelActor.VideoChannel
                      Severity: Minor
                      Found in server/core/lib/activitypub/videos/shared/creator.ts - About 1 hr to fix

                        Function _notifyVideoQualities has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private _notifyVideoQualities () {
                            if (!this.metadata) return
                        
                            const resolutions: PeerTubeResolution[] = []
                        
                        
                        Severity: Minor
                        Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 1 hr to fix

                          Function signup has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async signup () {
                              this.signupError = undefined
                          
                              const termsForm = this.formStepTerms.value
                              const userForm = this.formStepUser.value
                          Severity: Minor
                          Found in client/src/app/+signup/+register/register.component.ts - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language