Skip to content

Commit

Permalink
Merge pull request #1410 from tripal/tv4g0-issue1404-improveMaintaina…
Browse files Browse the repository at this point in the history
…bility

Improve Maintainability as suggested by CodeClimate
  • Loading branch information
spficklin committed Feb 10, 2023
2 parents 1b6bec1 + 773f55e commit c786dbf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ checks:
argument-count:
enabled: false
config:
threshold: 4
threshold: 8
complex-logic:
enabled: true
config:
Expand All @@ -16,7 +16,7 @@ checks:
method-complexity:
enabled: true
config:
threshold: 7
threshold: 25
method-count:
enabled: false
config:
Expand All @@ -38,7 +38,7 @@ checks:
config:
threshold: #language-specific defaults. overrides affect all languages.
identical-code:
enabled: true
enabled: false
config:
threshold: #language-specific defaults. overrides affect all languages.

Expand Down
35 changes: 24 additions & 11 deletions tripal_chado/src/Database/ChadoSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,31 @@ public function getMainTables() {
if (isset($schema['referring_tables'])) {
foreach ($schema['referring_tables'] as $tablename) {

// Ignore the cvterm tables, relationships, chadoprop tables.
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
preg_match('/prop$/', $tablename) || preg_match('/prop_.+$/', $tablename) ||
// Ignore nd_tables
preg_match('/^nd_/', $tablename)) {
continue;
$is_base_table = TRUE;

// Ignore the cvterm tables + chadoprop tables.
if (in_array($tablename, ['cvterm_dbxref', 'cvterm_relationship', 'cvtermpath', 'cvtermprop', 'chadoprop', 'cvtermsynonym'])) {
$is_base_table = FALSE;
}
// Ignore relationship linked tables.
elseif (preg_match('/_relationship$/', $tablename)) {
$is_base_table = FALSE;
}
// Ignore cvterm annotation linking tables.
elseif (preg_match('/_cvterm$/', $tablename)) {
$is_base_table = FALSE;
}
else {
// Ignore property tables.
elseif (preg_match('/prop$/', $tablename) || preg_match('/prop_.+$/', $tablename)) {
$is_base_table = FALSE;
}
// Ignore natural diversity tables.
elseif (preg_match('/^nd_/', $tablename)) {
$is_base_table = FALSE;
}

// If it's not any of the above then add it to the list.
if ($is_base_table === TRUE) {
array_push($base_tables, $tablename);
}
}
Expand Down
35 changes: 24 additions & 11 deletions tripal_chado/src/api/ChadoSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,31 @@ function getBaseTables() {
if (isset($schema['referring_tables'])) {
foreach ($schema['referring_tables'] as $tablename) {

// Ignore the cvterm tables, relationships, chadoprop tables.
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
preg_match('/prop$/', $tablename) || preg_match('/prop_.+$/', $tablename) ||
// Ignore nd_tables
preg_match('/^nd_/', $tablename)) {
continue;
$is_base_table = TRUE;

// Ignore the cvterm tables + chadoprop tables.
if (in_array($tablename, ['cvterm_dbxref', 'cvterm_relationship', 'cvtermpath', 'cvtermprop', 'chadoprop', 'cvtermsynonym'])) {
$is_base_table = FALSE;
}
// Ignore relationship linked tables.
elseif (preg_match('/_relationship$/', $tablename)) {
$is_base_table = FALSE;
}
// Ignore cvterm annotation linking tables.
elseif (preg_match('/_cvterm$/', $tablename)) {
$is_base_table = FALSE;
}
else {
// Ignore property tables.
elseif (preg_match('/prop$/', $tablename) || preg_match('/prop_.+$/', $tablename)) {
$is_base_table = FALSE;
}
// Ignore natural diversity tables.
elseif (preg_match('/^nd_/', $tablename)) {
$is_base_table = FALSE;
}

// If it's not any of the above then add it to the list.
if ($is_base_table === TRUE) {
array_push($base_tables, $tablename);
}
}
Expand Down

0 comments on commit c786dbf

Please sign in to comment.