Chocobozzz/PeerTube

View on GitHub

Showing 3,313 of 3,313 total issues

File videos-id-list-query-builder.ts has 592 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

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

      ngOnInit () {
        this.serverConfig = this.serverService.getHTMLConfig()
    
        const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = {
          instance: {

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

        async updateSecondStep () {
          if (!await this.isFormValid()) return
      
          this.video.patch(this.form.value)
          this.chaptersEdit.patch(this.form.value)
      client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts on lines 152..176

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

      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

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

        async updateSecondStep () {
          if (!await this.isFormValid()) return
      
          this.video.patch(this.form.value)
          this.chaptersEdit.patch(this.form.value)
      client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts on lines 156..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 239.

      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 customConfig has 248 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

        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

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

          import { DatePipe, NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'
          import {
            ChangeDetectorRef,
            Component,
            EventEmitter,
          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

              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

            File videos-command.ts has 538 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

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

                  RESOLUTIONS: {
                    get '0p' () { return config.get<boolean>('transcoding.resolutions.0p') },
                    get '144p' () { return config.get<boolean>('transcoding.resolutions.144p') },
                    get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') },
                    get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') },
              Severity: Major
              Found in server/core/initializers/config.ts and 1 other location - About 1 day to fix
              server/core/initializers/config.ts on lines 506..516

              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

                    RESOLUTIONS: {
                      get '0p' () { return config.get<boolean>('live.transcoding.resolutions.0p') },
                      get '144p' () { return config.get<boolean>('live.transcoding.resolutions.144p') },
                      get '240p' () { return config.get<boolean>('live.transcoding.resolutions.240p') },
                      get '360p' () { return config.get<boolean>('live.transcoding.resolutions.360p') },
              Severity: Major
              Found in server/core/initializers/config.ts and 1 other location - About 1 day to fix
              server/core/initializers/config.ts on lines 445..455

              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 54 (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

                export 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 202.

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

                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