Chocobozzz/PeerTube

View on GitHub

Showing 3,041 of 3,041 total issues

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

  ngOnInit () {
    this.serverConfig = this.serverService.getHTMLConfig()

    const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = {
      instance: {

    File videos-id-list-query-builder.ts has 571 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Sequelize, Transaction } from 'sequelize'
    import validator from 'validator'
    import { forceNumber } from '@peertube/peertube-core-utils'
    import { VideoInclude, VideoIncludeType, VideoPrivacy, VideoPrivacyType, VideoState } from '@peertube/peertube-models'
    import { exists } from '@server/helpers/custom-validators/misc.js'
    Severity: Major
    Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 1 day to fix

      File video-stats.component.ts has 564 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { ChartConfiguration, ChartData, ChartOptions, PluginOptionsByType, Scale, TooltipItem, defaults as ChartJSDefaults } from 'chart.js'
      import zoomPlugin from 'chartjs-plugin-zoom'
      import { Observable, of } from 'rxjs'
      import { SelectOptionsItem } from 'src/types'
      import { Component, Inject, LOCALE_ID, OnInit } from '@angular/core'
      Severity: Major
      Found in client/src/app/+stats/video/video-stats.component.ts - About 1 day to fix

        Function customConfig has 234 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function customConfig (): CustomConfig {
          return {
            instance: {
              name: CONFIG.INSTANCE.NAME,
              shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
        Severity: Major
        Found in server/core/controllers/api/config.ts - About 1 day to fix

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

            getUserAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {
              const { pagination, sort, search } = options
          
              let params = new HttpParams()
              params = this.restService.addRestGetParams(params, pagination, sort)
          Severity: Major
          Found in client/src/app/shared/shared-moderation/blocklist.service.ts and 1 other location - About 1 day to fix
          client/src/app/shared/shared-moderation/blocklist.service.ts on lines 105..118

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

          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

            getInstanceAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {
              const { pagination, sort, search } = options
          
              let params = new HttpParams()
              params = this.restService.addRestGetParams(params, pagination, sort)
          Severity: Major
          Found in client/src/app/shared/shared-moderation/blocklist.service.ts and 1 other location - About 1 day to fix
          client/src/app/shared/shared-moderation/blocklist.service.ts on lines 46..59

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

          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 create (options: CreateOptions) {
              const { video, resolution, fps, dependsOnRunnerJob, priority } = options
          
              const jobUUID = buildUUID()
          
          
          server/core/lib/runners/job-handlers/vod-web-video-transcoding-job-handler.ts on lines 30..62

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

          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 create (options: CreateOptions) {
              const { video, resolution, fps, priority, dependsOnRunnerJob } = options
          
              const jobUUID = buildUUID()
              const payload: RunnerJobVODWebVideoTranscodingPayload = {
          server/core/lib/runners/job-handlers/vod-hls-transcoding-job-handler.ts on lines 33..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 213.

          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

            private loadMoreFollowers (reset = false) {
              const pagination = this.restService.componentToRestPagination(this.followersPagination)
          
              this.followService.getFollowers({ pagination, sort: this.sort, state: 'accepted' })
                  .subscribe({
          client/src/app/+about/about-follows/about-follows.component.ts on lines 117..133

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

          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

            private loadMoreFollowings (reset = false) {
              const pagination = this.restService.componentToRestPagination(this.followingsPagination)
          
              this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' })
                  .subscribe({
          client/src/app/+about/about-follows/about-follows.component.ts on lines 99..115

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

          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

            getAdminAbuses (options: {
              pagination: RestPagination
              sort: SortMeta
              search?: string
            }): Observable<ResultList<AdminAbuse>> {
          Severity: Major
          Found in client/src/app/shared/shared-moderation/abuse.service.ts and 1 other location - About 1 day to fix
          client/src/app/shared/shared-moderation/abuse.service.ts on lines 53..72

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

          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

            getUserAbuses (options: {
              pagination: RestPagination
              sort: SortMeta
              search?: string
            }): Observable<ResultList<UserAbuse>> {
          Severity: Major
          Found in client/src/app/shared/shared-moderation/abuse.service.ts and 1 other location - About 1 day to fix
          client/src/app/shared/shared-moderation/abuse.service.ts on lines 32..51

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

          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

          Redis has 59 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Redis {
          
            private static instance: Redis
            private initialized = false
            private connected = false
          Severity: Major
          Found in server/core/lib/redis.ts - About 1 day to fix

            Function buildIdsListQuery has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
            Open

              private buildIdsListQuery (options: BuildVideosListQueryOptions) {
                this.attributes = options.attributes || [ '"video"."id"' ]
            
                if (options.group) this.group = options.group
                if (options.having) this.having = options.having
            Severity: Minor
            Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 1 day to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

            const videoFilesDeleteHLSValidator = [
              isValidVideoIdParam('id'),
            
              async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                if (areValidationErrors(req, res)) return
            Severity: Major
            Found in server/core/middlewares/validators/videos/video-files.ts and 1 other location - About 1 day to fix
            server/core/middlewares/validators/videos/video-files.ts on lines 8..35

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

            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 videoFilesDeleteWebVideoValidator = [
              isValidVideoIdParam('id'),
            
              async (req: express.Request, res: express.Response, next: express.NextFunction) => {
                if (areValidationErrors(req, res)) return
            Severity: Major
            Found in server/core/middlewares/validators/videos/video-files.ts and 1 other location - About 1 day to fix
            server/core/middlewares/validators/videos/video-files.ts on lines 72..99

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

            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

            File videos-command.ts has 510 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
            
            import validator from 'validator'
            import { getAllPrivacies, omit, pick, wait } from '@peertube/peertube-core-utils'
            import {
            Severity: Major
            Found in packages/server-commands/src/videos/videos-command.ts - About 1 day to fix

              File video-edit.component.ts has 509 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { forkJoin } from 'rxjs'
              import { map } from 'rxjs/operators'
              import { SelectChannelItem, SelectOptionsItem } from 'src/types/select-options-item.model'
              import { ChangeDetectorRef, Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
              import { AbstractControl, FormArray, FormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'
              Severity: Major
              Found in client/src/app/+videos/+video-edit/shared/video-edit.component.ts - About 1 day to fix

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

                  report () {
                    const reason = this.form.get('reason').value
                    const predefinedReasons = Object.keys(pickBy(this.form.get('predefinedReasons').value)) as AbusePredefinedReasonsString[]
                
                    this.abuseService.reportVideo({
                client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts on lines 87..105

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

                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

                  report () {
                    const reason = this.form.get('reason').value
                    const predefinedReasons = Object.keys(pickBy(this.form.get('predefinedReasons').value)) as AbusePredefinedReasonsString[]
                
                    this.abuseService.reportVideo({
                client/src/app/shared/shared-moderation/report-modals/account-report.component.ts on lines 88..106

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

                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