guillaumemonet/Rad

View on GitHub

Showing 34 of 80 total issues

Method getTableIndexes has 27 lines of code (exceeds 25 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

    Function generateParse has a Cognitive Complexity of 9 (exceeds 5 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 55 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 getTableColumns has a Cognitive Complexity of 9 (exceeds 5 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 55 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 createTableIfNotExists has a Cognitive Complexity of 9 (exceeds 5 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 55 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 generateIndexesGetter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generateIndexesGetter(ClassType $class, Table $table) {
            foreach ($table->indexes as $k => $i) {
                if ($i->name == "PRIMARY") {
                    $this->generatePrimaryIndexGetter($class, $k, $i);
                } else if ($i->unique) {
    Severity: Minor
    Found in src/Rad/Build/DatabaseBuilder/ClassesGeneratorStaticTrait.php - About 45 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 getColumnDefinition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function getColumnDefinition(string $column_name, array $column_info): string {
            $column_definition = $column_name . ' ' . $column_info['type'];
            $nodefault         = false;
            // Ajouter la taille si spécifiée dans les commentaires
            if (isset($column_info['length'])) {
    Severity: Minor
    Found in src/Rad/Model/ModelDatabase.php - About 45 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 getTableStructure has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getTableStructure($table) {
            $columns = [];
            $result  = Database::getHandler()->query("SHOW FULL COLUMNS FROM `$table`;");
            while ($row     = $result->fetch()) {
                $column       = new Column();
    Severity: Minor
    Found in src/Rad/Build/DatabaseBuilder/GeneratorTools.php - About 45 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

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

        public function call(string $endpoint, array $get = null, array $post = null, array $header = [], bool $caching = true);
    Severity: Minor
    Found in src/Rad/ClientApi/ClientApiInterface.php - About 35 mins to fix

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

          public function call(string $endpoint, array $get = null, array $post = null, array $headers = [], bool $caching = true) {
      Severity: Minor
      Found in src/Rad/ClientApi/ClientApiHandler.php - About 35 mins to fix

        Function addImageWithFade has a Cognitive Complexity of 6 (exceeds 5 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 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 loadTrads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function loadTrads() {
                $filePath = Config::getApiConfig()->install_path . $this->config->locales_path;
                if (file_exists($filePath)) {
                    $fileContents = file_get_contents($filePath);
                    if ($fileContents === false) {
        Severity: Minor
        Found in src/Rad/Language/LanguageHandler.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 generateProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generateProperties(ClassType $class, Table $table) {
                foreach ($table->columns as $col_name => $col) {
                    if (str_ends_with($col_name, "i18n") && $col->auto == 0 && !str_starts_with($table->name, "i18n")) {
                        $propertyName = str_replace("_i18n", "", $col_name);
                        $property     = $class->addProperty($propertyName)
        Severity: Minor
        Found in src/Rad/Build/DatabaseBuilder/ClassesGenerator.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public final function run(Closure $finalClosure = null, Closure $errorClosure = null): void {
                try {
                    $this->getRouter()
                            ->load($this->controllers)
                            ->route($this->request)
        Severity: Minor
        Found in src/Rad/Rad.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 generateClasses has a Cognitive Complexity of 6 (exceeds 5 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 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

        Severity
        Category
        Status
        Source
        Language