Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

Function createUserAccountAndChannelAndPlaylist has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function createUserAccountAndChannelAndPlaylist (parameters: {
  userToCreate: MUser
  userDisplayName?: string
  channelNames?: ChannelNames
  validateUser?: boolean
Severity: Minor
Found in server/core/lib/user.ts - About 1 hr to fix

    Function insertFromImportIntoDB has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function insertFromImportIntoDB (parameters: {
      video: MVideoThumbnail
      thumbnailModel: MThumbnail
      previewModel: MThumbnail
      videoChannel: MChannelAccountDefault
    Severity: Minor
    Found in server/core/lib/video-pre-import.ts - About 1 hr to fix

      Function onTranscriptionEnded has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export async function onTranscriptionEnded (options: {
        video: MVideoFullLight
        language: string
        vttPath: string
        lTags?: (string | number)[]
      Severity: Minor
      Found in server/core/lib/video-captions.ts - About 1 hr to fix

        Function checkVideoFileCanBeEdited has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function checkVideoFileCanBeEdited (video: MVideo, res: express.Response) {
          if (video.isLive) {
            res.fail({
              status: HttpStatusCode.BAD_REQUEST_400,
              message: 'Cannot edit a live video'

          Function checkVideoCanBeTranscribedOrTranscripted has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function checkVideoCanBeTranscribedOrTranscripted (video: MVideo, res: express.Response) {
            if (video.remote) {
              res.fail({
                status: HttpStatusCode.BAD_REQUEST_400,
                message: 'Cannot run this task on a remote video'

            Function importObject has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              protected async importObject (channelImportData: SanitizedObject) {
                const account = this.user.Account
                const existingChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(channelImportData.name)
            
                if (existingChannel) {
            Severity: Minor
            Found in server/core/lib/user-import-export/importers/channels-importer.ts - About 1 hr to fix

              Function saveNewOriginalFileIfNeeded has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function saveNewOriginalFileIfNeeded (video: MVideo, videoFile: MVideoFile) {
                if (!CONFIG.TRANSCODING.ORIGINAL_FILE.KEEP) return
              
                const videoSource = await VideoSourceModel.loadLatest(video.id)
              
              
              Severity: Minor
              Found in server/core/lib/video-file.ts - About 1 hr to fix

                Function crawlCollectionPage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) {
                  let url = argUrl
                
                  logger.info('Crawling ActivityPub data on %s.', url)
                
                
                Severity: Minor
                Found in server/core/lib/activitypub/crawl.ts - About 1 hr to fix

                  Function registerSourceHandler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const registerSourceHandler = function (vjs: typeof videojs) {
                    if (!Hlsjs.isSupported()) {
                      logger.info('Hls.js is not supported in this browser.')
                      return
                    }
                  Severity: Minor
                  Found in client/src/assets/player/shared/p2p-media-loader/hls-plugin.ts - About 1 hr to fix

                    Function doRefresh has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function doRefresh <T extends MActorFull | MActorAccountChannelId> (options: RefreshOptions<T>): RefreshResult <MActorFull> {
                      const { actor: actorArg, fetchedType } = options
                    
                      // We need more attributes
                      const actor = fetchedType === 'all'
                    Severity: Minor
                    Found in server/core/lib/activitypub/actors/refresh.ts - About 1 hr to fix

                      Function ngOnInit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        ngOnInit () {
                          this.confirmService.showConfirm.subscribe(
                            payload => {
                              // Reinit fields
                              this.title = ''
                      Severity: Minor
                      Found in client/src/app/modal/confirm.component.ts - About 1 hr to fix

                        Function generateCaptionOfSpecificVideo has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private generateCaptionOfSpecificVideo (options: {
                            video: Video
                            forceTranscription: boolean
                          }): Observable<'success' | 'already-has-captions' | 'already-being-transcribed'> {
                            const { video, forceTranscription } = options

                          Function checkTranscodingFields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private checkTranscodingFields () {
                              const transcodingControl = this.form.get('transcoding.enabled')
                              const videoStudioControl = this.form.get('videoStudio.enabled')
                              const hlsControl = this.form.get('transcoding.hls.enabled')
                              const webVideosControl = this.form.get('transcoding.webVideos.enabled')

                            Function subscribeToVideoRequests has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              private subscribeToVideoRequests () {
                                this.videoRequests
                                  .pipe(
                                    concatMap(({ reset, obsHighlightedLives, obsVideos }) => {
                                      return forkJoin([ obsHighlightedLives, obsVideos ])

                              Function constructChannel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                private constructChannel () {
                                  const channel = Channel.build({ window: window.parent, origin: '*', scope: this.embed.getScope() })
                              
                                  channel.bind('setVideoPassword', (txn, value) => this.embed.setVideoPasswordByAPI(value))
                              
                              
                              Severity: Minor
                              Found in client/src/standalone/videos/embed-api.ts - About 1 hr to fix

                                Function buildElement has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  async buildElement (text: string) {
                                    const html = await this.markdown.customPageMarkdownToHTML({ markdown: text, additionalAllowedTags: this.getSupportedTags() })
                                
                                    const rootElement = document.createElement('div')
                                    rootElement.innerHTML = html
                                Severity: Minor
                                Found in client/src/app/shared/shared-custom-markup/custom-markup.service.ts - About 1 hr to fix

                                  Function buildVODCommand has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    private async buildVODCommand (options: TranscodeVODOptions & {
                                      videoStreamOnly?: boolean
                                      canCopyAudio?: boolean
                                      canCopyVideo?: boolean
                                    }) {
                                  Severity: Minor
                                  Found in packages/ffmpeg/src/ffmpeg-vod.ts - About 1 hr to fix

                                    Function report has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      report (options: OverrideCommandOptions & {
                                        reason: string
                                    
                                        accountId?: number
                                        videoId?: number
                                    Severity: Minor
                                    Found in packages/server-commands/src/moderation/abuses-command.ts - About 1 hr to fix

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

                                          WEB_VIDEOS: {
                                            BUCKET_NAME: config.get<string>('object_storage.web_videos.bucket_name'),
                                            PREFIX: config.get<string>('object_storage.web_videos.prefix'),
                                            BASE_URL: config.get<string>('object_storage.web_videos.base_url')
                                          },
                                      Severity: Major
                                      Found in server/core/initializers/config.ts and 2 other locations - About 1 hr to fix
                                      server/core/initializers/config.ts on lines 162..166
                                      server/core/initializers/config.ts on lines 167..171

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

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

                                            it('Should enable signup without approval', async () => {
                                              await prepareSignup({ enabled: true, requiresApproval: false, requiresEmailVerification: false })
                                      
                                              await signupPage.getRegisterMenuButton().waitForDisplayed()
                                            })
                                      Severity: Major
                                      Found in client/e2e/src/suites-local/signup.e2e-spec.ts and 3 other locations - About 1 hr to fix
                                      client/e2e/src/suites-local/signup.e2e-spec.ts on lines 175..179
                                      client/e2e/src/suites-local/signup.e2e-spec.ts on lines 256..260
                                      client/e2e/src/suites-local/signup.e2e-spec.ts on lines 324..328

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

                                      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