guillaumemonet/Rad

View on GitHub

Showing 34 of 80 total issues

File ModelDatabase.php has 435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
 * @author Guillaume Monet
Severity: Minor
Found in src/Rad/Model/ModelDatabase.php - About 6 hrs to fix

    Function getClassAttributes has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function getClassAttributes(string $class_name): array {
            $reflectionClass  = new ReflectionClass($class_name);
            $class_attributes = [
                'table'        => '',
                'columns'      => [],
    Severity: Minor
    Found in src/Rad/Model/ModelDatabase.php - About 5 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

    Function loadStructure has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function loadStructure(string $table_name, string $file_name): string {
            // Récupérer les informations sur la structure de la table depuis la base de données
            $columns      = self::getTableColumns($table_name);
            $indexes      = self::getTableIndexes($table_name);
            $foreign_keys = self::getTableForeignKeys($table_name);
    Severity: Minor
    Found in src/Rad/Model/ModelDatabase.php - About 4 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 getClassAttributes has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function getClassAttributes(string $class_name): array {
            $reflectionClass  = new ReflectionClass($class_name);
            $class_attributes = [
                'table'        => '',
                'columns'      => [],
    Severity: Major
    Found in src/Rad/Model/ModelDatabase.php - About 2 hrs to fix

      Function updateTableIndexes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function updateTableIndexes(string $table_name, array $indexes, array $existing_indexes) {
              $pdo = Database::getHandler();
      
              // Mettre à jour les indexes uniques
              $existing_unique_indexes = $existing_indexes['unique'];
      Severity: Minor
      Found in src/Rad/Model/ModelDatabase.php - About 2 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 generateCreate has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generateCreate(ClassType $class, Table $table) {
              $parse = $class->addMethod('create');
              $parse->setVisibility('public');
      
              $parse->addParameter("force")->setDefaultValue(false)->setType("bool");
      Severity: Major
      Found in src/Rad/Build/DatabaseBuilder/ClassesGenerator.php - About 2 hrs to fix

        Method loadStructure has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function loadStructure(string $table_name, string $file_name): string {
                // Récupérer les informations sur la structure de la table depuis la base de données
                $columns      = self::getTableColumns($table_name);
                $indexes      = self::getTableIndexes($table_name);
                $foreign_keys = self::getTableForeignKeys($table_name);
        Severity: Major
        Found in src/Rad/Model/ModelDatabase.php - About 2 hrs to fix

          Method updateTableIndexes has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function updateTableIndexes(string $table_name, array $indexes, array $existing_indexes) {
                  $pdo = Database::getHandler();
          
                  // Mettre à jour les indexes uniques
                  $existing_unique_indexes = $existing_indexes['unique'];
          Severity: Minor
          Found in src/Rad/Model/ModelDatabase.php - About 1 hr to fix

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

                private static function getTableIndexes(string $table_name): array {
                    $indexes = ['primary' => [], 'unique' => [], 'key' => []];
                    // Récupérer les informations sur les indexes depuis la base de données
                    $pdo     = Database::getHandler();
            
            
            Severity: Minor
            Found in src/Rad/Model/ModelDatabase.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 generateParse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function generateParse(ClassType $class, Table $table) {
                    $parse = $class->addMethod('parse');
                    $parse->setVisibility('public');
                    $parse->addParameter("row")->setType("array");
                    foreach ($table->columns as $col_name => $col) {
            Severity: Minor
            Found in src/Rad/Build/DatabaseBuilder/ClassesGenerator.php - About 1 hr to fix

              Method generateOneToManys has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function generateOneToManys(ClassType $class, Table $table) {
              
                      foreach ($table->onetomany as $k => $ref_tables) {
                          $parse      = $class->addMethod('getAll' . StringUtils::camelCase($k));
                          $parse->setVisibility('public');
              Severity: Minor
              Found in src/Rad/Build/DatabaseBuilder/ClassesGenerator.php - About 1 hr to fix

                Method parseDocComment has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function parseDocComment(string $doc_comment): array {
                        $attributes = [];
                
                        // Utiliser StringUtils::parseComments pour analyser les annotations
                        $annotations = StringUtils::parseComments($doc_comment);
                Severity: Minor
                Found in src/Rad/Model/ModelDatabase.php - About 1 hr to fix

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

                      public function generateCreate(ClassType $class, Table $table) {
                          $parse = $class->addMethod('create');
                          $parse->setVisibility('public');
                  
                          $parse->addParameter("force")->setDefaultValue(false)->setType("bool");
                  Severity: Minor
                  Found in src/Rad/Build/DatabaseBuilder/ClassesGenerator.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

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

                      private static function parseDocComment(string $doc_comment): array {
                          $attributes = [];
                  
                          // Utiliser StringUtils::parseComments pour analyser les annotations
                          $annotations = StringUtils::parseComments($doc_comment);
                  Severity: Minor
                  Found in src/Rad/Model/ModelDatabase.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 addImageWithFade has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function addImageWithFade($imagePath, $position, $step = 30) {
                          // Créer une image vide blanche de dimensions 1200x500
                          $canvas          = imagecreatetruecolor(1200, 500);
                          $backgroundColor = imagecolorallocate($canvas, 255, 255, 255);
                          imagefill($canvas, 0, 0, $backgroundColor);
                  Severity: Minor
                  Found in src/Rad/Utils/Image.php - About 1 hr to fix

                    Method generateClasses has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function generateClasses(array $tables) {
                            foreach ($tables as $name => $table) {
                                if (strpos($name, "_has_") !== false) {
                                    continue;
                                }
                    Severity: Minor
                    Found in src/Rad/Build/DatabaseBuildHandler.php - About 1 hr to fix

                      Method getTableColumns has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private static function getTableColumns(string $table_name): array {
                              $columns = [];
                              // Récupérer les informations sur les colonnes depuis la base de données
                              $sql     = "SHOW COLUMNS FROM $table_name";
                              $result  = Database::getHandler()->query($sql);
                      Severity: Minor
                      Found in src/Rad/Model/ModelDatabase.php - About 1 hr to fix

                        Method createTableIfNotExists has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static function createTableIfNotExists(string $table_name, array $columns, array $indexes) {
                                $pdo = Database::getHandler();
                        
                                // Vérifier si la table existe déjà dans la base de données
                                $query        = "SHOW TABLES LIKE '$table_name'";
                        Severity: Minor
                        Found in src/Rad/Model/ModelDatabase.php - About 1 hr to fix

                          Function getText has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function getText(string $value, $domaine = "default", $locale = null): ?string {
                                  $locale = $locale ?? $this->default_locale;
                          
                                  if (!isset($this->trads[$domaine][$value][$locale])) {
                                      if (!isset($this->trads[$domaine])) {
                          Severity: Minor
                          Found in src/Rad/Language/LanguageHandler.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

                          Function updateTableColumns has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private static function updateTableColumns(string $table_name, array $columns, array $existing_columns) {
                                  $pdo = Database::getHandler();
                          
                                  // Vérifier si chaque nouvelle colonne doit être ajoutée à la table
                                  foreach ($columns as $column_name => $column_info) {
                          Severity: Minor
                          Found in src/Rad/Model/ModelDatabase.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

                          Severity
                          Category
                          Status
                          Source
                          Language