fisharebest/webtrees

View on GitHub
app/Auth.php

Summary

Maintainability
D
2 days
Test Coverage

Auth has 27 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 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

      Similar blocks of code found in 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 550..569

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

          public static function checkSharedNoteAccess(?SharedNote $shared_note, bool $edit = false): SharedNote
          {
              $message = I18N::translate('This note does not exist or you do not have permission to view it.');
      
              if ($shared_note === null) {
      Severity: Major
      Found in app/Auth.php and 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 492..511
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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 11 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 10 other locations - About 1 hr to fix
      app/Auth.php on lines 226..245
      app/Auth.php on lines 255..274
      app/Auth.php on lines 318..337
      app/Auth.php on lines 347..366
      app/Auth.php on lines 376..395
      app/Auth.php on lines 405..424
      app/Auth.php on lines 434..453
      app/Auth.php on lines 463..482
      app/Auth.php on lines 521..540
      app/Auth.php on lines 550..569

      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