tripal_chado/src/api/ChadoSchema.php

Summary

Maintainability
C
1 day
Test Coverage
F
54%

Function getBaseTables has a Cognitive Complexity of 23 (exceeds 7 allowed). Consider refactoring.
Open

  function getBaseTables() {

    // Initialize the base tables with those tables that are missing a type.
    // Ideally they should have a type, but that's for a future version of Chado.
    $base_tables = [
Severity: Minor
Found in tripal_chado/src/api/ChadoSchema.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

Consider simplifying this complex logical expression.
Open

        if ($tablename == 'cvterm_dbxref' || $tablename == 'cvterm_relationship' ||
          $tablename == 'cvtermpath' || $tablename == 'cvtermprop' || $tablename == 'chadoprop' ||
          $tablename == 'cvtermsynonym' || preg_match('/_relationship$/', $tablename) ||
          preg_match('/_cvterm$/', $tablename) ||
          // Ignore prop tables
Severity: Critical
Found in tripal_chado/src/api/ChadoSchema.php - About 2 hrs to fix

    Function checkColumnType has a Cognitive Complexity of 16 (exceeds 7 allowed). Consider refactoring.
    Open

      public function checkColumnType($table, $column, $expected_type = NULL) {
    
        // Ensure this column exists before moving forward.
        if (!$this->checkColumnExists($table, $column)) {
          tripal_report_error(
    Severity: Minor
    Found in tripal_chado/src/api/ChadoSchema.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 createTableSql has a Cognitive Complexity of 14 (exceeds 7 allowed). Consider refactoring.
    Open

       function createTableSql($name, $table) {
        $sql_fields = [];
        foreach ($table['fields'] as $field_name => $field) {
          $sql_fields[] = $this
            ->createFieldSql($field_name, $this
    Severity: Minor
    Found in tripal_chado/src/api/ChadoSchema.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 getTableSchema has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
    Open

      public function getTableSchema($table) {
    
        $schema = $this->getSchemaDetails();
    
        $table_arr =  FALSE;
    Severity: Minor
    Found in tripal_chado/src/api/ChadoSchema.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 processField has a Cognitive Complexity of 11 (exceeds 7 allowed). Consider refactoring.
    Open

      function processField($field) {
        if (!isset($field['size'])) {
          $field['size'] = 'normal';
        }
    
    
    Severity: Minor
    Found in tripal_chado/src/api/ChadoSchema.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 createFieldSql has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring.
    Open

      function createFieldSql($name, $spec) {
    
        // The PostgreSQL server converts names into lowercase, unless quoted.
        $sql = '"' . $name . '" ' . $spec['pgsql_type'];
        if (isset($spec['type']) && $spec['type'] == 'serial') {
    Severity: Minor
    Found in tripal_chado/src/api/ChadoSchema.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 checkSequenceExists has a Cognitive Complexity of 9 (exceeds 7 allowed). Consider refactoring.
    Open

      public function checkSequenceExists($table, $column, $sequence_name = NULL) {
    
        if ($sequence_name === NULL) {
    
          // Ensure they gave us a table.
    Severity: Minor
    Found in tripal_chado/src/api/ChadoSchema.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

    Avoid too many return statements within this method.
    Open

          return FALSE;
    Severity: Major
    Found in tripal_chado/src/api/ChadoSchema.php - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status