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 resultList = await AccountVideoRateModel.listByAccountForApi({
    accountId: account.id,
    start: req.query.start,
    count: req.query.count,
    sort: req.query.sort,
Severity: Major
Found in server/core/controllers/api/accounts.ts and 1 other location - About 2 hrs to fix
server/core/controllers/api/video-playlist.ts on lines 143..149

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

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

  deleteImport (videoImport: VideoImport) {
    this.videoImportService.deleteVideoImport(videoImport)
      .subscribe({
        next: () => this.reloadData(),

client/src/app/+my-library/my-video-imports/my-video-imports.component.ts on lines 113..120

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

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

  getAuditLogs (options: OverrideCommandOptions & {
    startDate: Date
    endDate?: Date
  }) {
    const { startDate, endDate } = options
Severity: Major
Found in packages/server-commands/src/logs/logs-command.ts and 1 other location - About 2 hrs to fix
packages/server-commands/src/server/plugins-command.ts on lines 177..192

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

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

  accept (options: OverrideCommandOptions & { id: number } & UserRegistrationUpdateState) {
    const { id } = options
    const path = '/api/v1/users/registrations/' + id + '/accept'

    return this.postBodyRequest({
Severity: Major
Found in packages/server-commands/src/users/registrations-command.ts and 1 other location - About 2 hrs to fix
packages/server-commands/src/users/registrations-command.ts on lines 70..82

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

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

  cancelImport (videoImport: VideoImport) {
    this.videoImportService.cancelVideoImport(videoImport)
      .subscribe({
        next: () => this.reloadData(),

client/src/app/+my-library/my-video-imports/my-video-imports.component.ts on lines 104..111

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

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 resultList = await VideoPlaylistModel.listForApi({
    followerActorId: serverActor.id,
    start: req.query.start,
    count: req.query.count,
    sort: req.query.sort,
Severity: Major
Found in server/core/controllers/api/video-playlist.ts and 1 other location - About 2 hrs to fix
server/core/controllers/api/accounts.ts on lines 244..250

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

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 user-notitication-list-query-builder.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Sequelize } from 'sequelize'
import { AbstractRunQuery, ModelBuilder } from '@server/models/shared/index.js'
import { UserNotificationModelForApi } from '@server/types/models/index.js'
import { ActorImageType } from '@peertube/peertube-models'
import { getSort } from '../../shared/index.js'
Severity: Minor
Found in server/core/models/user/sql/user-notitication-list-query-builder.ts - About 2 hrs to fix

    VideoCaptionModel has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Scopes(() => ({
      [ScopeNames.WITH_VIDEO_UUID_AND_REMOTE]: {
        include: [
          {
            attributes: [ 'id', 'uuid', 'remote' ],
    Severity: Minor
    Found in server/core/models/video/video-caption.ts - About 2 hrs to fix

      RegisterHelpers has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class RegisterHelpers {
        private readonly transcodingProfiles: {
          [ npmName: string ]: {
            type: 'vod' | 'live'
            encoder: string
      Severity: Minor
      Found in server/core/lib/plugins/register-helpers.ts - About 2 hrs to fix

        AccountsComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        @Component({
          templateUrl: './accounts.component.html',
          styleUrls: [ './accounts.component.scss' ],
          standalone: true,
          imports: [
        Severity: Minor
        Found in client/src/app/+accounts/accounts.component.ts - About 2 hrs to fix

          VideoCommentComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @Component({
            selector: 'my-video-comment',
            templateUrl: './video-comment.component.html',
            styleUrls: [ './video-comment.component.scss' ],
            standalone: true,

            UsersCommand has 21 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class UsersCommand extends AbstractCommand {
            
              askResetPassword (options: OverrideCommandOptions & {
                email: string
              }) {
            Severity: Minor
            Found in packages/server-commands/src/users/users-command.ts - About 2 hrs to fix

              Function up has 54 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function up (utils: {
                transaction: Sequelize.Transaction
                queryInterface: Sequelize.QueryInterface
                sequelize: Sequelize.Sequelize
              }): Promise<void> {
              Severity: Major
              Found in server/core/initializers/migrations/0765-remote-transcoding.ts - About 2 hrs to fix

                Function updateVideoPlaylist has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function updateVideoPlaylist (req: express.Request, res: express.Response) {
                  const videoPlaylistInstance = res.locals.videoPlaylistFull
                  const videoPlaylistInfoToUpdate = req.body as VideoPlaylistUpdate
                
                  const wasPrivatePlaylist = videoPlaylistInstance.privacy === VideoPlaylistPrivacy.PRIVATE
                Severity: Major
                Found in server/core/controllers/api/video-playlist.ts - About 2 hrs to fix

                  Function buildRegisterHelpers has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    buildRegisterHelpers (): RegisterServerOptions {
                      const registerHook = this.buildRegisterHook()
                      const registerSetting = this.buildRegisterSetting()
                  
                      const getRouter = this.buildGetRouter()
                  Severity: Major
                  Found in server/core/lib/plugins/register-helpers.ts - About 2 hrs to fix

                    Function getPlayerLoadOptions has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async getPlayerLoadOptions (options: {
                        video: VideoDetails
                        captionsResponse: Response
                    
                        storyboardsResponse: Response
                    Severity: Major
                    Found in client/src/standalone/videos/shared/player-options-builder.ts - About 2 hrs to fix

                      Function assignCommands has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private assignCommands () {
                          this.bulk = new BulkCommand(this)
                          this.cli = new CLICommand(this)
                          this.customPage = new CustomPagesCommand(this)
                          this.feed = new FeedCommand(this)
                      Severity: Major
                      Found in packages/server-commands/src/server/server.ts - About 2 hrs to fix

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

                          updateCustomConfig (options: OverrideCommandOptions & {
                            newCustomConfig: CustomConfig
                          }) {
                            const path = '/api/v1/config/custom'
                        
                        
                        Severity: Major
                        Found in packages/server-commands/src/server/config-command.ts and 3 other locations - About 2 hrs to fix
                        packages/server-commands/src/logs/logs-command.ts on lines 6..17
                        packages/server-commands/src/server/metrics-command.ts on lines 6..17
                        packages/server-commands/src/users/notifications-command.ts on lines 6..19

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

                        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

                          addPlaybackMetric (options: OverrideCommandOptions & { metrics: PlaybackMetricCreate }) {
                            const path = '/api/v1/metrics/playback'
                        
                            return this.postBodyRequest({
                              ...options,
                        Severity: Major
                        Found in packages/server-commands/src/server/metrics-command.ts and 3 other locations - About 2 hrs to fix
                        packages/server-commands/src/logs/logs-command.ts on lines 6..17
                        packages/server-commands/src/server/config-command.ts on lines 548..561
                        packages/server-commands/src/users/notifications-command.ts on lines 6..19

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

                        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

                          updateMySettings (options: OverrideCommandOptions & {
                            settings: UserNotificationSetting
                          }) {
                            const path = '/api/v1/users/me/notification-settings'
                        
                        
                        Severity: Major
                        Found in packages/server-commands/src/users/notifications-command.ts and 3 other locations - About 2 hrs to fix
                        packages/server-commands/src/logs/logs-command.ts on lines 6..17
                        packages/server-commands/src/server/config-command.ts on lines 548..561
                        packages/server-commands/src/server/metrics-command.ts on lines 6..17

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

                        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