RocketORM/ORM

View on GitHub

Showing 46 of 46 total issues

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

    protected function generateBase(Schema $schema)
    {
        $outputDirectory = $schema->absoluteDirectory . DIRECTORY_SEPARATOR . 'Base';
        $this->createDirectory($outputDirectory);

Severity: Major
Found in src/Rocket/ORM/Generator/Model/Query/QueryGenerator.php and 1 other location - About 3 hrs to fix
src/Rocket/ORM/Generator/Model/Object/ObjectGenerator.php on lines 93..112

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

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

    protected function generateBase(Schema $schema)
    {
        $outputDirectory = $schema->absoluteDirectory . DIRECTORY_SEPARATOR . 'Base';
        $this->createDirectory($outputDirectory);

Severity: Major
Found in src/Rocket/ORM/Generator/Model/Object/ObjectGenerator.php and 1 other location - About 3 hrs to fix
src/Rocket/ORM/Generator/Model/Query/QueryGenerator.php on lines 90..109

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

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

Query has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Query implements QueryInterface
{
    const JOIN_TYPE_INNER = 'INNER';
    const JOIN_TYPE_LEFT  = 'LEFT';
Severity: Minor
Found in src/Rocket/ORM/Model/Query/Query.php - About 2 hrs to fix

    Function transformColumns has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function transformColumns(array $columns)
        {
            foreach ($columns as $column) {
                if (null == $column->phpName) {
                    $column->phpName = StringUtil::camelize($column->name, false);
    Severity: Minor
    Found in src/Rocket/ORM/Generator/Schema/Transformer/SchemaTransformer.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

    TableMap has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class TableMap implements TableMapInterface
    {
        const COLUMN_TYPE_INTEGER  = 1;
        const COLUMN_TYPE_STRING   = 2;
        const COLUMN_TYPE_DOUBLE   = 3;
    Severity: Minor
    Found in src/Rocket/ORM/Model/Map/TableMap.php - About 2 hrs to fix

      Method getTableColumnConfigurationNode has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getTableColumnConfigurationNode()
          {
              $builder = new TreeBuilder();
              $columnsNode = $builder->root('columns');
              $columnsNode
      Severity: Major
      Found in src/Rocket/ORM/Generator/Schema/Configuration/SchemaConfiguration.php - About 2 hrs to fix

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

            public function generate(Schema $schema)
            {
                // First generate base
                $this->generateBase($schema);
        
        
        Severity: Major
        Found in src/Rocket/ORM/Generator/Model/Object/ObjectGenerator.php and 1 other location - About 2 hrs to fix
        src/Rocket/ORM/Generator/Model/Query/QueryGenerator.php on lines 63..85

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

        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

            public function generate(Schema $schema)
            {
                // First generate base
                $this->generateBase($schema);
        
        
        Severity: Major
        Found in src/Rocket/ORM/Generator/Model/Query/QueryGenerator.php and 1 other location - About 2 hrs to fix
        src/Rocket/ORM/Generator/Model/Object/ObjectGenerator.php on lines 66..88

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

        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

        Method pluralize has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function pluralize($word)
            {
                static $plurals = [
                    '/(quiz)$/i'                => '\1zes',
                    '/^(ox)$/i'                 => '\1en',
        Severity: Minor
        Found in src/Rocket/ORM/Generator/Utils/StringUtil.php - About 1 hr to fix

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

              protected function execute(InputInterface $input, OutputInterface $output)
              {
                  $schemas = $this->getSchemas($this->getSchemaPath());
                  $connections = [];
                  $pendingDatabaseCount = 0;
          Severity: Minor
          Found in src/Rocket/ORM/Command/RocketDatabaseCreateCommand.php - About 1 hr to fix

            Function execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function execute(InputInterface $input, OutputInterface $output)
                {
                    $schemas = $this->getSchemas($this->getSchemaPath());
                    $connections = [];
                    $pendingDatabaseCount = 0;
            Severity: Minor
            Found in src/Rocket/ORM/Command/RocketDatabaseCreateCommand.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 getTableRelationConfigurationNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function getTableRelationConfigurationNode()
                {
                    $onActionBehaviors = ['CASCADE', 'NO ACTION', 'RESTRICT', 'SET NULL', 'SET DEFAULT'];
            
                    $builder = new TreeBuilder();

              Method hydrateRelation has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function hydrateRelation(array $data, array $item, $alias)
                  {
                      $hash = Rocket::getTableMap($this->joins[$alias]['relation']['namespace'])->getPrimaryKeysHash($item);
                      $relationFrom = $this->joins[$alias]['from'];
                      $relationPhpName = $this->joins[$alias]['relation']['phpName'];
              Severity: Minor
              Found in src/Rocket/ORM/Model/Query/Hydrator/ComplexQueryHydrator.php - About 1 hr to fix

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

                    protected function buildClauses()
                    {
                        $query = ' WHERE ';
                
                        // FIXME handle the case when a clause need to be encapsulated by parentheses
                Severity: Minor
                Found in src/Rocket/ORM/Model/Query/Query.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 save has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function save(\PDO $con = null)
                    {
                        if ($this->_isDeleted) {
                            throw new \LogicException('Cannot save a deleted object');
                        }
                Severity: Minor
                Found in src/Rocket/ORM/Model/Model.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 load has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function load($path, array $options)
                    {
                        if (null != $path) {
                            if (!is_file($path)) {
                                throw new ConfigurationFileNotFoundException('The rocket configuration file is not found in the selected folder "' . $path . '"');
                Severity: Minor
                Found in src/Rocket/ORM/Config/ConfigLoader.php - About 1 hr to fix

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

                      protected function load($path, array $options)
                      {
                          if (null != $path) {
                              if (!is_file($path)) {
                                  throw new ConfigurationFileNotFoundException('The rocket configuration file is not found in the selected folder "' . $path . '"');
                  Severity: Minor
                  Found in src/Rocket/ORM/Config/ConfigLoader.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 transformColumns has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function transformColumns(array $columns)
                      {
                          foreach ($columns as $column) {
                              if (null == $column->phpName) {
                                  $column->phpName = StringUtil::camelize($column->name, false);
                  Severity: Minor
                  Found in src/Rocket/ORM/Generator/Schema/Transformer/SchemaTransformer.php - About 1 hr to fix

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

                        protected function join($relation, $alias, $joinType = self::JOIN_TYPE_INNER, $with = false)
                        {
                            $relationTable = $relation;
                            $from = null;
                    
                    Severity: Minor
                    Found in src/Rocket/ORM/Model/Query/Query.php - About 1 hr to fix

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

                          protected function validateRelations(array $normalizedSchemas)
                          {
                              $transformerClass = $this->options['transformer']['relation']['class'];
                              if (is_object($transformerClass)) {
                                  $schemaRelationTransformer = $transformerClass;
                      Severity: Minor
                      Found in src/Rocket/ORM/Generator/Schema/Loader/SchemaLoader.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