propelorm/Propel2

View on GitHub

Showing 740 of 740 total issues

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

    public function objectFilter(string &$script): void
    {
        $p = new PhpParser($script, true);
        $text = (string)$p->findMethod('toArray');
        $matches = [];
Severity: Minor
Found in src/Propel/Generator/Behavior/Delegate/DelegateBehavior.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 queryMethods has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function queryMethods(QueryBuilder $builder): string
    {
        $script = '';

        foreach ($this->delegates as $delegate => $type) {
Severity: Minor
Found in src/Propel/Generator/Behavior/Delegate/DelegateBehavior.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 addValidateMethod has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addValidateMethod(): string
    {
        $table = $this->getTable();
        $foreignKeys = $table->getForeignKeys();
        $hasForeignKeys = (count($foreignKeys) != 0);
Severity: Minor
Found in src/Propel/Generator/Behavior/Validate/ValidateBehavior.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 objectFilter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function objectFilter(string &$script, AbstractOMBuilder $builder): void
    {
        if ($this->behavior->useScope()) {
            if ($this->behavior->hasMultipleScopes()) {
                foreach ($this->behavior->getScopes() as $idx => $scope) {

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

    public function modifyTable(): void
    {
        $table = $this->getTable();

        if (!$table->hasColumn($this->getParameter('rank_column'))) {
Severity: Minor
Found in src/Propel/Generator/Behavior/Sortable/SortableBehavior.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 modifyDatabase has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function modifyDatabase(): void
    {
        foreach ($this->getDatabase()->getTables() as $table) {
            if ($table->hasBehavior($this->getId())) {
                // don't add the same behavior twice
Severity: Minor
Found in src/Propel/Generator/Behavior/Versionable/VersionableBehavior.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 staticAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function staticAttributes(AbstractOMBuilder $builder): string
    {
        $tableName = $this->table->getName();
        $col = '';

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

    protected function isDeleteCascadeEmulationNeeded(): bool
    {
        $table = $this->getTable();
        if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
            foreach ($table->getReferrers() as $fk) {
Severity: Minor
Found in src/Propel/Generator/Builder/Om/QueryBuilder.php and 1 other location - About 30 mins to fix
src/Propel/Generator/Builder/Om/QueryBuilder.php on lines 304..316

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

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 isDeleteSetNullEmulationNeeded(): bool
    {
        $table = $this->getTable();
        if ((!$this->getPlatform()->supportsNativeDeleteTrigger() || $this->getBuildProperty('generator.objectModel.emulateForeignKeyConstraints')) && count($table->getReferrers()) > 0) {
            foreach ($table->getReferrers() as $fk) {
Severity: Minor
Found in src/Propel/Generator/Builder/Om/QueryBuilder.php and 1 other location - About 30 mins to fix
src/Propel/Generator/Builder/Om/QueryBuilder.php on lines 285..297

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

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

Avoid too many return statements within this method.
Open

                return true;
Severity: Major
Found in src/Propel/Runtime/ActiveQuery/Criteria.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return new BinaryCriterion($criteria, $column, $value, $comparison);
    Severity: Major
    Found in src/Propel/Runtime/ActiveQuery/Criterion/CriterionFactory.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in src/Propel/Runtime/ActiveQuery/Criteria.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return new BasicCriterion($criteria, $column, $value, $comparison);
        Severity: Major
        Found in src/Propel/Runtime/ActiveQuery/Criterion/CriterionFactory.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return new BasicModelCriterion($this, $clause, $colMap, $value, $this->currentAlias);
          Severity: Major
          Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return new LikeCriterion($criteria, $column, $value, $comparison);
            Severity: Major
            Found in src/Propel/Runtime/ActiveQuery/Criterion/CriterionFactory.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                      return false;
              Severity: Major
              Found in src/Propel/Runtime/ActiveQuery/Criteria.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return new CustomCriterion($this, $clause);
                Severity: Major
                Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return [null, null];
                  Severity: Major
                  Found in src/Propel/Runtime/ActiveQuery/ModelCriteria.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return false;
                    Severity: Major
                    Found in src/Propel/Runtime/ActiveQuery/Criteria.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return false;
                      Severity: Major
                      Found in src/Propel/Runtime/ActiveQuery/Criteria.php - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language