fisharebest/webtrees

View on GitHub
app/Auth.php

Summary

Maintainability
D
2 days
Test Coverage

Auth has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class Auth
{
    // Privacy constants
    public const PRIV_PRIVATE = 2; // Allows visitors to view the item
    public const PRIV_USER    = 1; // Allows members to access the item
Severity: Minor
Found in app/Auth.php - About 3 hrs to fix

    File Auth.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * webtrees: online genealogy
     * Copyright (C) 2021 webtrees development team
    Severity: Minor
    Found in app/Auth.php - About 2 hrs to fix

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

          public static function checkHeaderAccess(?Header $header, bool $edit = false): Header
          {
              $message = I18N::translate('This record does not exist or you do not have permission to view it.');
      
              if ($header === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkRepositoryAccess(?Repository $repository, bool $edit = false): Repository
          {
              $message = I18N::translate('This repository does not exist or you do not have permission to view it.');
      
              if ($repository === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkFamilyAccess(?Family $family, bool $edit = false): Family
          {
              $message = I18N::translate('This family does not exist or you do not have permission to view it.');
      
              if ($family === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkMediaAccess(?Media $media, bool $edit = false): Media
          {
              $message = I18N::translate('This media object does not exist or you do not have permission to view it.');
      
              if ($media === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkSourceAccess(?Source $source, bool $edit = false): Source
          {
              $message = I18N::translate('This source does not exist or you do not have permission to view it.');
      
              if ($source === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkLocationAccess(?Location $location, bool $edit = false): Location
          {
              $message = I18N::translate('This record does not exist or you do not have permission to view it.');
      
              if ($location === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkSubmissionAccess(?Submission $submission, bool $edit = false): Submission
          {
              $message = I18N::translate('This record does not exist or you do not have permission to view it.');
      
              if ($submission === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507

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

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

          public static function checkNoteAccess(?Note $note, bool $edit = false): Note
          {
              $message = I18N::translate('This note does not exist or you do not have permission to view it.');
      
              if ($note === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkRecordAccess(?GedcomRecord $record, bool $edit = false): GedcomRecord
          {
              $message = I18N::translate('This record does not exist or you do not have permission to view it.');
      
              if ($record === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 488..507
      app/Auth.php on lines 517..536

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

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

          public static function checkSubmitterAccess(?Submitter $submitter, bool $edit = false): Submitter
          {
              $message = I18N::translate('This record does not exist or you do not have permission to view it.');
      
              if ($submitter === null) {
      Severity: Major
      Found in app/Auth.php and 9 other locations - About 1 hr to fix
      app/Auth.php on lines 222..241
      app/Auth.php on lines 251..270
      app/Auth.php on lines 314..333
      app/Auth.php on lines 343..362
      app/Auth.php on lines 372..391
      app/Auth.php on lines 401..420
      app/Auth.php on lines 430..449
      app/Auth.php on lines 459..478
      app/Auth.php on lines 517..536

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

      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

      There are no issues that match your filters.

      Category
      Status