piotrpolak/pepiscms

View on GitHub
pepiscms/modules/development/libraries/ModuleGenerator.php

Summary

Maintainability
F
4 days
Test Coverage

File ModuleGenerator.php has 588 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PepisCMS
 *
Severity: Major
Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 1 day to fix

    Function makeUserSpaceModule has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        public function makeUserSpaceModule($module_database_table_name,
                                            $module_name,
                                            $auto_install = true,
                                            $parse_database_schema = true,
                                            $database_group = false,
    Severity: Minor
    Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 6 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

    ModuleGenerator has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ModuleGenerator extends ContainerAware
    {
        /**
         * @var \PiotrPolak\PepisCMS\Modulerunner\ModuleLocatorInterface
         */
    Severity: Minor
    Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 6 hrs to fix

      Method makeUserSpaceModule has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function makeUserSpaceModule($module_database_table_name,
                                              $module_name,
                                              $auto_install = true,
                                              $parse_database_schema = true,
                                              $database_group = false,
      Severity: Major
      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 3 hrs to fix

        Method prepareReplacementTokens has 13 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private function prepareReplacementTokens($module_database_table_name,
                                                      $module_name,
                                                      $module_label,
                                                      $module_name_singular,
                                                      $definition_output,
        Severity: Major
        Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 1 hr to fix

          Function generateCall has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              private function generateCall($value, $datagrid_constants, $formbuilder_constants, $tabs)
              {
                  $definition_output = '';
                  foreach ($value as $v_key => $v_value) {
                      if ($v_key == 'filter_type') {
          Severity: Minor
          Found in pepiscms/modules/development/libraries/ModuleGenerator.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 makeUserSpaceModule has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function makeUserSpaceModule($module_database_table_name,
                                                  $module_name,
                                                  $auto_install = true,
                                                  $parse_database_schema = true,
                                                  $database_group = false,
          Severity: Major
          Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 1 hr to fix

            Method generateSecurityPolicy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function generateSecurityPolicy($module_name, $module_name_singular, $policy_save_path)
                {
                    $method_default_access = array(
                        'index' => 'READ',
                        'edit' => 'WRITE',
            Severity: Minor
            Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 1 hr to fix

              Method buildTranslations has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function buildTranslations($module_name, $translations, $module_label, $language_pairs, $directory, $module_name_lower_case)
              Severity: Minor
              Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 45 mins to fix

                Method generatePublicStuffIfNeccesary has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private function generatePublicStuffIfNeccesary($generate_public_controller, $directory, $module_name_lower_case, $template_base_path, array $data)
                Severity: Minor
                Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 35 mins to fix

                  Method generateCrudStuffIfNecessary has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      private function generateCrudStuffIfNecessary($is_crud, $directory, $template_base_path, array $data, $module_name_lower_case)
                  Severity: Minor
                  Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 35 mins to fix

                    Method generateOrRegenerateModel has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        private function generateOrRegenerateModel($directory, $module_name_lower_case, $module_name_singular, $template_base_path, array $data)
                    Severity: Minor
                    Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 35 mins to fix

                      Function regenerateSetAcceptedFieldsForExistingModel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function regenerateSetAcceptedFieldsForExistingModel($file_model_path, $data)
                          {
                              // Replace acceptable fields
                              $model_file_contents_exploded = file($file_model_path, FILE_IGNORE_NEW_LINES);
                              if (count($model_file_contents_exploded) > 0) {
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 35 mins 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

                      Function generateFilterElement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function generateFilterElement($value, $key)
                          {
                              $filters_element = '';
                              foreach ($value as $v_key => $v_value) {
                                  if ($v_key == 'filter_type') {
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 35 mins 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

                      Function getCreatedAtFieldName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getCreatedAtFieldName($available_field_names, $definition)
                          {
                              foreach ($available_field_names as $available_field_name) {
                                  if (strpos($available_field_name, 'create') !== false) {
                                      // Input type check
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 25 mins 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

                      Function mergeLanguageTranslationPairs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function mergeLanguageTranslationPairs($translation_file_path, $language_pairs)
                          {
                              // Merging existing translations with the new pairs
                              if (file_exists($translation_file_path)) {
                                  $existing_language_pairs = $this->languagehelper->getLanguageByPath($translation_file_path);
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 25 mins 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

                      Function getImageFieldNameBestMatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getImageFieldNameBestMatch($available_field_names, $possible_image_field_names)
                          {
                              foreach ($available_field_names as $available_field_name) {
                                  foreach ($possible_image_field_names as $possible_image_field_name) {
                                      if (strpos($available_field_name, $possible_image_field_name) !== false) {
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 25 mins 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

                      Function getOrderFieldName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getOrderFieldName($available_field_names, $definition)
                          {
                              $possible_order_field_names = array('item_order', 'position', 'pos');
                      
                              foreach ($possible_order_field_names as $possible_order_field_name) {
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 25 mins 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

                      Function getUpdatedAtFieldName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function getUpdatedAtFieldName($available_field_names, $definition)
                          {
                              foreach ($available_field_names as $available_field_name) {
                                  if (strpos($available_field_name, 'update') !== false) {
                                      // Input type check
                      Severity: Minor
                      Found in pepiscms/modules/development/libraries/ModuleGenerator.php - About 25 mins 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

                      There are no issues that match your filters.

                      Category
                      Status