DerDu/SPHERE-Framework

View on GitHub
Application/Setting/Consumer/Service/Data.php

Summary

Maintainability
F
4 days
Test Coverage

Method setupDatabaseContent has 269 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setupDatabaseContent()
    {

        if (($tblSetting = $this->createSetting('People', 'Meta', 'Student', 'Automatic_StudentNumber',
            TblSetting::TYPE_BOOLEAN, '0'))) {
Severity: Major
Found in Application/Setting/Consumer/Service/Data.php - About 1 day to fix

    File Data.php has 482 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace SPHERE\Application\Setting\Consumer\Service;
    
    use SPHERE\Application\Contact\Address\Service\Entity\TblAddress;
    Severity: Minor
    Found in Application/Setting/Consumer/Service/Data.php - About 7 hrs to fix

      Function setupDatabaseContent has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setupDatabaseContent()
          {
      
              if (($tblSetting = $this->createSetting('People', 'Meta', 'Student', 'Automatic_StudentNumber',
                  TblSetting::TYPE_BOOLEAN, '0'))) {
      Severity: Minor
      Found in Application/Setting/Consumer/Service/Data.php - About 7 hrs 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

      Method getSettingByConsumer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getSettingByConsumer(TblSetting $tblSetting, TblConsumer $tblConsumer)
          {
      
              $value = '';
              $connection = false;
      Severity: Minor
      Found in Application/Setting/Consumer/Service/Data.php - About 1 hr to fix

        Function getSettingByConsumer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getSettingByConsumer(TblSetting $tblSetting, TblConsumer $tblConsumer)
            {
        
                $value = '';
                $connection = false;
        Severity: Minor
        Found in Application/Setting/Consumer/Service/Data.php - About 1 hr 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

        Method createSetting has 9 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                $Cluster,
                $Application,
                $Module,
                $Identifier,
                $Type,
        Severity: Major
        Found in Application/Setting/Consumer/Service/Data.php - About 1 hr to fix

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

              public function updateSetting(TblSetting $tblSetting, $value)
              {
                  $Manager = $this->getConnection()->getEntityManager();
          
                  /** @var TblSetting $Entity */
          Severity: Major
          Found in Application/Setting/Consumer/Service/Data.php and 13 other locations - About 2 hrs to fix
          Application/Billing/Bookkeeping/Basket/Service/Data.php on lines 639..656
          Application/Education/Certificate/Generate/Service/Data.php on lines 279..299
          Application/Education/Certificate/Prepare/Service/Data.php on lines 1642..1662
          Application/Education/Certificate/Prepare/Service/Data.php on lines 1729..1749
          Application/Education/Certificate/Prepare/Service/Data.php on lines 1799..1819
          Application/Education/Graduation/Gradebook/MinimumGradeCount/Data.php on lines 230..250
          Application/Education/Lesson/Division/Service/Data.php on lines 2033..2050
          Application/Education/Lesson/Division/Service/Data.php on lines 2298..2315
          Application/Reporting/CheckList/Service/Data.php on lines 69..84
          Application/Reporting/CheckList/Service/Data.php on lines 567..584
          Application/Reporting/CheckList/Service/Data.php on lines 696..713
          Application/Reporting/Individual/Service/Data.php on lines 219..238
          Application/Reporting/SerialLetter/Service/Data.php on lines 619..635

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

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

              public function removeStudentCustody(TblStudentCustody $tblStudentCustody)
              {
                  $Manager = $this->getConnection()->getEntityManager();
          
                  $Entity = $Manager->getEntity('TblStudentCustody')->findOneBy(array('Id' => $tblStudentCustody->getId()));
          Severity: Major
          Found in Application/Setting/Consumer/Service/Data.php and 15 other locations - About 1 hr to fix
          Application/Billing/Bookkeeping/Basket/Service/Data.php on lines 766..784
          Application/Billing/Bookkeeping/Basket/Service/Data.php on lines 819..833
          Application/Billing/Inventory/Item/Service/Data.php on lines 681..699
          Application/Education/Certificate/Generator/Service/Data.php on lines 4453..4466
          Application/Education/Certificate/Generator/Service/Data.php on lines 4473..4486
          Application/Education/Certificate/Generator/Service/Data.php on lines 4631..4644
          Application/Education/Certificate/Generator/Service/Data.php on lines 4651..4664
          Application/Education/Lesson/Division/Service/Data.php on lines 1601..1614
          Application/Education/Lesson/Division/Service/Data.php on lines 1621..1634
          Application/Education/Lesson/Division/Service/Data.php on lines 2411..2426
          Application/Education/Lesson/Subject/Service/Data.php on lines 399..413
          Application/Education/Lesson/Subject/Service/Data.php on lines 420..434
          Application/Education/Lesson/Term/Service/Data.php on lines 191..205
          Application/Education/Lesson/Term/Service/Data.php on lines 212..226
          Application/Education/Lesson/Term/Service/Data.php on lines 871..886

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

          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