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 (isTranscriptionPayloadSuccess(payload) && payload.vttFile) {
      attaches[`payload[vttFile]`] = payload.vttFile

      payloadWithoutFiles = omit(payloadWithoutFiles as TranscriptionSuccess, [ 'vttFile' ])
    }
Severity: Major
Found in packages/server-commands/src/runners/runner-jobs-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/runners/runner-jobs-command.ts on lines 195..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 59.

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

        socket.on('unsubscribe', params => {
          const videoId = params.videoId + ''
          if (!isIdValid(videoId)) return

          /* eslint-disable @typescript-eslint/no-floating-promises */
Severity: Major
Found in server/core/lib/peertube-socket.ts and 1 other location - About 1 hr to fix
server/core/lib/peertube-socket.ts on lines 50..56

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

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.linkType === 'external') {
      this.routerLink = null
      this.playlistHref = this.playlist.url
      this.playlistTarget = '_blank'
      return
client/src/app/shared/shared-video-miniature/video-miniature.component.ts on lines 169..174

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

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 addReplyToLastThread (options: OverrideCommandOptions & {
    text: string
  }) {
    return this.addReply({ ...options, videoId: this.lastVideoId, toCommentId: this.lastThreadId })
  }
Severity: Major
Found in packages/server-commands/src/videos/comments-command.ts and 1 other location - About 1 hr to fix
packages/server-commands/src/videos/comments-command.ts on lines 176..180

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

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

  static async getStats (strategy: VideoRedundancyStrategyWithManual) {
    const actor = await getServerActor()

    const sql = `WITH "tmp" AS ` +
      `(` +
Severity: Minor
Found in server/core/models/redundancy/video-redundancy.ts - About 1 hr to fix

    Function toActivityPubObject has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      toActivityPubObject (this: MVideoRedundancyAP): CacheFileObject {
        if (this.VideoStreamingPlaylist) {
          return {
            id: this.url,
            type: 'CacheFile' as 'CacheFile',
    Severity: Minor
    Found in server/core/models/redundancy/video-redundancy.ts - About 1 hr to fix

      Function acceptRegistration has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function acceptRegistration (req: express.Request, res: express.Response) {
        const registration = res.locals.userRegistration
        const body: UserRegistrationUpdateState = req.body
      
        const userToCreate = buildUser({
      Severity: Minor
      Found in server/core/controllers/api/users/registrations.ts - About 1 hr to fix

        Function areValidationErrors has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function areValidationErrors (
          req: express.Request,
          res: express.Response,
          options: {
            omitLog?: boolean
        Severity: Minor
        Found in server/core/middlewares/validators/shared/utils.ts - About 1 hr to fix

          Function onExternalUserAuthenticated has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function onExternalUserAuthenticated (options: {
            npmName: string
            authName: string
            authResult: RegisterServerExternalAuthenticatedResult
          }) {
          Severity: Minor
          Found in server/core/lib/auth/external-auth.ts - About 1 hr to fix

            Function autoBlacklistVideoIfNeeded has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async function autoBlacklistVideoIfNeeded (parameters: {
              video: MVideoWithBlacklistLight
              user?: MUser
              isRemote: boolean
              isNew: boolean
            Severity: Minor
            Found in server/core/lib/video-blacklist.ts - About 1 hr to fix

              Function updateUserFromExternal has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function updateUserFromExternal (
                user: MUserDefault,
                userOptions: ExternalUser,
                userUpdater: RegisterServerAuthenticatedResult['userUpdater']
              ) {
              Severity: Minor
              Found in server/core/lib/auth/oauth-model.ts - About 1 hr to fix

                Function init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  init () {
                    const events = this.getContext().nodeEvent
                    events.on('postPublish', (sessionId: string, streamPath: string) => {
                      logger.debug('RTMP received stream', { id: sessionId, streamPath, ...lTags(sessionId) })
                
                
                Severity: Minor
                Found in server/core/lib/live/live-manager.ts - About 1 hr to fix

                  Function cacheFileActivityObjectToDBAttributes has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function cacheFileActivityObjectToDBAttributes (cacheFileObject: CacheFileObject, video: MVideoWithAllFiles, byActor: MActorId) {
                  
                    if (cacheFileObject.url.mediaType === 'application/x-mpegURL') {
                      const url = cacheFileObject.url
                  
                  
                  Severity: Minor
                  Found in server/core/lib/activitypub/cache-file.ts - About 1 hr to fix

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

                      async create (options: CreateOptions) {
                        const { video, resolution, fps, priority, dependsOnRunnerJob } = options
                    
                        const jobUUID = buildUUID()
                        const { separatedAudioFile } = video.getMaxQualityAudioAndVideoFiles()

                      Function createTranscodingJobs has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async createTranscodingJobs (options: {
                          transcodingType: 'hls' | 'webtorrent' | 'web-video' // TODO: remove webtorrent in v7
                          video: MVideoFullLight
                          resolutions: number[]
                          isNewVideo: boolean

                        Function optimizeOriginalVideofile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export async function optimizeOriginalVideofile (options: {
                          video: MVideoFullLight
                          quickTranscode: boolean
                          job: Job
                        }) {
                        Severity: Minor
                        Found in server/core/lib/transcoding/web-transcoding.ts - About 1 hr to fix

                          Function displayFatalError has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            displayFatalError () {
                              // Already displayed an error
                              if (this.errorModal) return
                          
                              debugLogger('Display fatal error')
                          Severity: Minor
                          Found in client/src/assets/player/shared/peertube/peertube-plugin.ts - About 1 hr to fix

                            Function getMetadataStream has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              private getMetadataStream (streams: any[], type: 'video' | 'audio') {
                                const stream = streams.find(s => s.codec_type === type)
                                if (!stream) return undefined
                            
                                let keyToTranslateFunction = {

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

                                constructor (hash: ServerVideoPlaylist, translations: { [ id: string ]: string }) {
                                  const absoluteAPIUrl = getAbsoluteAPIUrl()
                              
                                  this.id = hash.id
                                  this.uuid = hash.uuid
                              Severity: Minor
                              Found in client/src/app/shared/shared-video-playlist/video-playlist.model.ts - About 1 hr to fix

                                Function viewReplies has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  viewReplies (commentId: number, highlightThread = false) {
                                    this.threadLoading[commentId] = true
                                
                                    const params = {
                                      videoId: this.video.uuid,
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language