brokencube/automatorm

View on GitHub

Showing 452 of 452 total issues

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

<?php
namespace Automatorm\Orm;

use Automatorm\Exception;
use Automatorm\Database\SqlString;
Severity: Major
Found in src/Orm/Data.php - About 1 day to fix

    Function generate has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generate()
        {
            $data = $this->connection->data;
            $database = $this->connection->schemaName;
            
    Severity: Minor
    Found in src/DataLayer/Fake/SchemaGenerator.php - About 1 day 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 generate has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generate()
        {
            $connection = $this->connection;
            
            $model = [];
    Severity: Minor
    Found in src/DataLayer/Database/SchemaGenerator.php - About 1 day 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

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

                if ($columnparts[5] ?: $columnparts[6]) {
                    $this->database = $this->escape($columnparts[1] ?: $columnparts[2]);
                    $this->schema = $this->escape($columnparts[3] ?: $columnparts[4]);
                    $this->column = $this->escape($columnparts[5] ?: $columnparts[6]);
                } elseif ($columnparts[3] ?: $columnparts[4]) {
    Severity: Major
    Found in src/Database/QueryBuilder/Column.php and 1 other location - About 7 hrs to fix
    src/Database/QueryBuilder/Table.php on lines 39..50

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

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

                if ($columnparts[5] ?: $columnparts[6]) {
                    $this->database = $this->escape($columnparts[1] ?: $columnparts[2]);
                    $this->schema = $this->escape($columnparts[3] ?: $columnparts[4]);
                    $this->table = $this->escape($columnparts[5] ?: $columnparts[6]);
                } elseif ($columnparts[3] ?: $columnparts[4]) {
    Severity: Major
    Found in src/Database/QueryBuilder/Table.php and 1 other location - About 7 hrs to fix
    src/Database/QueryBuilder/Column.php on lines 45..56

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

    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

    Function filter has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        public function filter($filter, $invertAffix = false)
        {
            $copy = $this->container;
            
            if (is_array($filter)) {
    Severity: Minor
    Found in src/Orm/Collection.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 generateData has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generateData($connection)
        {
            list($schema, $database) = $connection->getSchemaGenerator()->generate();
            
            $currentTable = null;
    Severity: Minor
    Found in src/DataLayer/Fake/Data.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 format has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function format($key, $value, $seen = [], $collectionCount = 0, $exceptionThrown = false)
        {
            switch (true) {
                case $value instanceof Model:
                    $namespace = explode('\\', get_class($value));
    Severity: Minor
    Found in src/Orm/Dump.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

    Data has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Data
    {
        protected $data = [];           // Data from columns on this table
        protected $external = [];       // Links to foreign key objects
        
    Severity: Minor
    Found in src/Orm/Data.php - About 5 hrs to fix

      Method generate has 129 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generate()
          {
              $connection = $this->connection;
              
              $model = [];
      Severity: Major
      Found in src/DataLayer/Database/SchemaGenerator.php - About 5 hrs to fix

        Method format has 113 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function format($key, $value, $seen = [], $collectionCount = 0, $exceptionThrown = false)
            {
                switch (true) {
                    case $value instanceof Model:
                        $namespace = explode('\\', get_class($value));
        Severity: Major
        Found in src/Orm/Dump.php - About 4 hrs to fix

          QueryBuilder has 35 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class QueryBuilder
          {
              const ENGINES = ['mysql', 'postgres', 'mssql'];
              public static $engine = "mysql";
              public static $requireWhereClause = true;
          Severity: Minor
          Found in src/Database/QueryBuilder.php - About 4 hrs to fix

            Function generate has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function generate($path, Schema $schema)
                {
                    $namespace = $schema->namespace;
                    
                    foreach ($schema->model as $model) {
            Severity: Minor
            Found in src/Generator/Model.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

            Function commit has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

                public function commit($mode, $table, $id, $data, $externalData, $schema) : int
                {
                    if ($mode == 'delete') {
                        $this->data->delete($table, $id);
                        return $id;
            Severity: Minor
            Found in src/DataLayer/Fake/DataAccess.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

            Collection has 32 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Collection implements \ArrayAccess, \Iterator, \Countable, \JsonSerializable
            {
                // From Hodgepodge
                protected $container = [];
            
            
            Severity: Minor
            Found in src/Orm/Collection.php - About 4 hrs to fix

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

                  public function generate()
                  {
                      $data = $this->connection->data;
                      $database = $this->connection->schemaName;
                      
              Severity: Major
              Found in src/DataLayer/Fake/SchemaGenerator.php - About 3 hrs to fix

                File QueryBuilder.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Query Builder - build SQL queries programatically
                 *
                 * @package Automatorm\Database
                Severity: Minor
                Found in src/Database/QueryBuilder.php - About 3 hrs to fix

                  Function __construct has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __construct($column)
                      {
                          // Cowardly refuse to process SqlStrings
                          if ($column instanceof SqlString) {
                              $this->column = (string) $column;
                  Severity: Minor
                  Found in src/Database/QueryBuilder/Column.php - About 3 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 dumpModel has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function dumpModel(Model $model)
                      {
                          $data_access = function ($var) {
                              return $this->$var;
                          };
                  Severity: Minor
                  Found in src/Orm/Dump.php - About 3 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 dumpModel has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function dumpModel(Model $model)
                      {
                          $data_access = function ($var) {
                              return $this->$var;
                          };
                  Severity: Major
                  Found in src/Orm/Dump.php - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language