j4mie/idiorm

View on GitHub

Showing 19 of 19 total issues

File idiorm.php has 1223 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

    /**
     *
     * Idiorm
Severity: Major
Found in idiorm.php - About 3 days to fix

    ORM has 152 functions (exceeds 20 allowed). Consider refactoring.
    Open

        class ORM implements ArrayAccess {
    
            // ----------------------- //
            // --- CLASS CONSTANTS --- //
            // ----------------------- //
    Severity: Major
    Found in idiorm.php - About 3 days to fix

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

              public function save() {
                  $query = array();
      
                  // remove any expression fields as they are already baked into the query
                  $values = array_values(array_diff_key($this->_dirty_fields, $this->_expr_fields));
      Severity: Minor
      Found in idiorm.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 _log_query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

              protected static function _log_query($query, $parameters, $connection_name, $query_time) {
                  // If logging is not enabled, do nothing
                  if (!self::$_config[$connection_name]['logging']) {
                      return false;
                  }
      Severity: Minor
      Found in idiorm.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

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

              public function _add_having_placeholder($column_name, $separator, $values) {
                  if (!is_array($column_name)) {
                      $data = array($column_name => $values);
                  } else {
                      $data = $column_name;
      Severity: Major
      Found in idiorm.php and 1 other location - About 1 hr to fix
      idiorm.php on lines 1167..1180

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

      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 _add_where_placeholder($column_name, $separator, $values) {
                  if (!is_array($column_name)) {
                      $data = array($column_name => $values);
                  } else {
                      $data = $column_name;
      Severity: Major
      Found in idiorm.php and 1 other location - About 1 hr to fix
      idiorm.php on lines 1122..1135

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

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

              public function id($disallow_null = false) {
                  $id = $this->get($this->_get_id_column_name());
      
                  if ($disallow_null) {
                      if (is_array($id)) {
      Severity: Minor
      Found in idiorm.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 save has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function save() {
                  $query = array();
      
                  // remove any expression fields as they are already baked into the query
                  $values = array_values(array_diff_key($this->_dirty_fields, $this->_expr_fields));
      Severity: Minor
      Found in idiorm.php - About 1 hr to fix

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

                protected static function _execute($query, $parameters = array(), $connection_name = self::DEFAULT_CONNECTION) {
                    $statement = self::get_db($connection_name)->prepare($query);
                    self::$_last_statement = $statement;
                    $time = microtime(true);
        
        
        Severity: Minor
        Found in idiorm.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 _normalise_select_many_columns has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

                protected function _normalise_select_many_columns($columns) {
                    $return = array();
                    foreach($columns as $column) {
                        if(is_array($column)) {
                            foreach($column as $key => $value) {
        Severity: Minor
        Found in idiorm.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 _log_query has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                protected static function _log_query($query, $parameters, $connection_name, $query_time) {
                    // If logging is not enabled, do nothing
                    if (!self::$_config[$connection_name]['logging']) {
                        return false;
                    }
        Severity: Minor
        Found in idiorm.php - About 1 hr to fix

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

                  public function where_any_is($values, $operator='=') {
                      $data = array();
                      $query = array("((");
                      $first = true;
                      foreach ($values as $value) {
          Severity: Minor
          Found in idiorm.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 _set_orm_property has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function _set_orm_property($key, $value = null, $expr = false) {
                      if (!is_array($key)) {
                          $key = array($key => $value);
                      }
                      foreach ($key as $field => $value) {
          Severity: Minor
          Found in idiorm.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 _call_aggregate_db_function has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function _call_aggregate_db_function($sql_function, $column) {
                      $alias = strtolower($sql_function);
                      $sql_function = strtoupper($sql_function);
                      if('*' != $column) {
                          $column = $this->_quote_identifier($column);
          Severity: Minor
          Found in idiorm.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 _create_placeholders has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function _create_placeholders($fields) {
                      if(!empty($fields)) {
                          $db_fields = array();
                          foreach($fields as $key => $value) {
                              // Process expression fields directly into the query
          Severity: Minor
          Found in idiorm.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 _add_simple_condition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  protected function _add_simple_condition($type, $column_name, $separator, $value) {
                      $multiple = is_array($column_name) ? $column_name : array($column_name => $value);
                      $result = $this;
          
                      foreach($multiple as $key => $val) {
          Severity: Minor
          Found in idiorm.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 configure has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  public static function configure($key, $value = null, $connection_name = self::DEFAULT_CONNECTION) {
                      self::_setup_db_config($connection_name); //ensures at least default config is set
          
                      if (is_array($key)) {
                          // Shortcut: If only one array argument is passed,
          Severity: Minor
          Found in idiorm.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 select_many_expr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function select_many_expr() {
                      $columns = func_get_args();
                      if(!empty($columns)) {
                          $columns = $this->_normalise_select_many_columns($columns);
                          foreach($columns as $alias => $column) {
          Severity: Minor
          Found in idiorm.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 select_many has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function select_many() {
                      $columns = func_get_args();
                      if(!empty($columns)) {
                          $columns = $this->_normalise_select_many_columns($columns);
                          foreach($columns as $alias => $column) {
          Severity: Minor
          Found in idiorm.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