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 data = {
      type: Sequelize.DATE,
      allowNull: true,
      defaultValue: null
server/core/initializers/migrations/0790-thumbnail-disk.ts on lines 29..37

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

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 function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) {
  return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
}
Severity: Major
Found in server/core/lib/activitypub/url.ts and 1 other location - About 1 hr to fix
server/core/lib/activitypub/url.ts on lines 28..30

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

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

  stepForward () {
    let stepChild = 0

    if (this.focusedChild_ !== undefined) {
      stepChild = this.focusedChild_ + 1
client/src/assets/player/shared/settings/menu-focus-fixed.ts on lines 34..41

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

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

  stepBack () {
    let stepChild = 0

    if (this.focusedChild_ !== undefined) {
      stepChild = this.focusedChild_ - 1
client/src/assets/player/shared/settings/menu-focus-fixed.ts on lines 25..32

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

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 function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
server/core/initializers/migrations/0795-duplicate-runner-name.ts on lines 3..15

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

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

  canGenerateTranscription () {
    if (!this.user) return false

    return this.video.canGenerateTranscription(this.user, this.serverService.getHTMLConfig().videoTranscription.enabled)
  }
client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts on lines 202..206

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

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

@Component({
  selector: 'my-video-list',
  templateUrl: './video-list.component.html',
  styleUrls: [ './video-list.component.scss' ],
  standalone: true,
client/src/app/shared/shared-share-modal/video-share.component.ts on lines 58..333

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

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

    try {
      await fillAvatarSizeIfNeeded(account)
      await generateSmallerAvatarIfNeeded(account)
    } catch (err) {
      console.error(`Cannot process account avatar ${account.name}`, err)
Severity: Major
Found in server/scripts/migrations/peertube-4.2.ts and 1 other location - About 1 hr to fix
server/scripts/migrations/peertube-4.2.ts on lines 59..64

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

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

@Component({
  selector: 'my-video-share',
  templateUrl: './video-share.component.html',
  styleUrls: [ './video-share.component.scss' ],
  standalone: true,
client/src/app/+admin/overview/videos/video-list.component.ts on lines 35..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 56.

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

function createAccountAbuse (options: {
  baseAbuse: FilteredModelAttributes<AbuseModel>
  accountInstance: MAccountDefault
  transaction: Transaction
  reporterAccount: MAccountDefault
Severity: Major
Found in server/core/lib/moderation.ts and 1 other location - About 1 hr to fix
server/core/lib/moderation.ts on lines 145..174

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

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

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
Severity: Minor
Found in server/core/initializers/migrations/0560-user-feed-token.ts - About 1 hr to fix

    Function setSort has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private setSort (sort: string) {
        if (sort === '-originallyPublishedAt' || sort === 'originallyPublishedAt') {
          this.attributes.push('COALESCE("video"."originallyPublishedAt", "video"."publishedAt") AS "publishedAtForOrder"')
        }
    
    
    Severity: Minor
    Found in server/core/models/video/sql/video/videos-id-list-query-builder.ts - About 1 hr to fix

      Function usersCheckCurrentPasswordFactory has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const usersCheckCurrentPasswordFactory = (targetUserIdGetter: (req: express.Request) => number | string) => {
        return [
          body('currentPassword').optional().custom(exists),
      
          async (req: express.Request, res: express.Response, next: express.NextFunction) => {
      Severity: Minor
      Found in server/core/middlewares/validators/users/users.ts - About 1 hr to fix

        Function ensureCanAccessPrivateVideoHLSFiles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async (req: express.Request, res: express.Response, next: express.NextFunction) => {
            if (areValidationErrors(req, res)) return
        
            const videoUUID = basename(dirname(req.originalUrl))
        
        
        Severity: Minor
        Found in server/core/middlewares/validators/static.ts - About 1 hr to fix

          Function buildUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function buildUser (options: {
            username: string
            password: string
            email: string
          
          
          Severity: Minor
          Found in server/core/lib/user.ts - About 1 hr to fix

            Function buildCounters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              buildCounters () {
                this.errorsCounter = this.meter.createCounter('peertube_playback_errors_count', {
                  description: 'Errors collected from PeerTube player.'
                })
            
            
            Severity: Minor
            Found in server/core/lib/opentelemetry/metric-helpers/playback-metrics.ts - About 1 hr to fix

              Function copyOrRegenerateThumbnails has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function copyOrRegenerateThumbnails (options: {
                liveVideo: MVideoThumbnail
                replayVideo: MVideoWithFileThumbnail
              }) {
                const { liveVideo, replayVideo } = options
              Severity: Minor
              Found in server/core/lib/job-queue/handlers/video-live-ending.ts - About 1 hr to fix

                Function checkUserCanApproveVideoComment has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function checkUserCanApproveVideoComment (user: MUserAccountUrl, videoComment: MCommentOwnerVideoReply, res: express.Response) {
                  if (videoComment.isDeleted()) {
                    res.fail({
                      status: HttpStatusCode.CONFLICT_409,
                      message: 'This comment is deleted'
                Severity: Minor
                Found in server/core/middlewares/validators/videos/video-comments.ts - About 1 hr to fix

                  Function result has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const result = await VideoPathManager.Instance.makeAvailableVideoFile(inputVideoFile, async audioInputPath => {
                        const videoOutputPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname)
                  
                        // If the user updates the video preview during transcoding
                        const previewPath = video.getPreview().getPath()
                  Severity: Minor
                  Found in server/core/lib/transcoding/web-transcoding.ts - About 1 hr to fix

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

                      async create (options: CreateOptions) {
                        const { video, resolution, fps, priority, dependsOnRunnerJob } = options
                    
                        const jobUUID = buildUUID()
                        const payload: RunnerJobVODAudioMergeTranscodingPayload = {
                      Severity
                      Category
                      Status
                      Source
                      Language