openva/rs-video-processor

View on GitHub
bin/resolve_chyrons.php

Summary

Maintainability
C
1 day
Test Coverage

File resolve_chyrons.php has 403 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

require_once __DIR__ . '/../includes/settings.inc.php';
require_once __DIR__ . '/../includes/functions.inc.php';

Severity: Minor
Found in bin/resolve_chyrons.php - About 5 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            if (
                (substr($chyron['raw_text'], 0, 2) == 's8')
                ||
                (substr($chyron['raw_text'], 0, 2) == '58')
                ||
    Severity: Critical
    Found in bin/resolve_chyrons.php - About 2 hrs to fix

      Define a constant instead of duplicating this literal "file_id" 5 times.
      Open

                  WHERE file_id=' . $video['file_id'] . ' AND type="bill" AND linked_id IS NULL
      Severity: Critical
      Found in bin/resolve_chyrons.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "complete" 6 times.
      Open

              $legislator['complete'] = $legislator['prefix'] . ' ' . pivot($legislator['name']) . "\r"
      Severity: Critical
      Found in bin/resolve_chyrons.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "prefix" 6 times.
      Open

                  $legislator['prefix'] = 'Del.';
      Severity: Critical
      Found in bin/resolve_chyrons.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "raw_text" 51 times.
      Open

              $chyron['raw_text'] = str_replace(' ', '', $chyron['raw_text']);
      Severity: Critical
      Found in bin/resolve_chyrons.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "place" 3 times.
      Open

                  . $legislator['place'] . ' (' . $legislator['party'] . '-' . $legislator['district'] . ')';
      Severity: Critical
      Found in bin/resolve_chyrons.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "linked_id" 3 times.
      Open

                      insert_match($resolved['linked_id'], $unresolved['id']);
      Severity: Critical
      Found in bin/resolve_chyrons.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

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

              if (
                  (substr($chyron['raw_text'], 0, 2) == 's8')
                  ||
                  (substr($chyron['raw_text'], 0, 2) == '58')
                  ||
      Severity: Major
      Found in bin/resolve_chyrons.php and 2 other locations - About 55 mins to fix
      bin/resolve_chyrons.php on lines 132..142
      bin/resolve_chyrons.php on lines 142..152

      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 3 locations. Consider refactoring.
      Open

              } elseif (
                  (substr($chyron['raw_text'], 0, 2) == 'I ')
                  ||
                  (substr($chyron['raw_text'], 0, 2) == '| ')
                  ||
      Severity: Major
      Found in bin/resolve_chyrons.php and 2 other locations - About 55 mins to fix
      bin/resolve_chyrons.php on lines 116..152
      bin/resolve_chyrons.php on lines 132..142

      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 3 locations. Consider refactoring.
      Open

              } elseif (
                  (substr($chyron['raw_text'], 0, 3) == 'hjr')
                  ||
                  (substr($chyron['raw_text'], 0, 3) == 'pur')
                  ||
      Severity: Major
      Found in bin/resolve_chyrons.php and 2 other locations - About 55 mins to fix
      bin/resolve_chyrons.php on lines 116..152
      bin/resolve_chyrons.php on lines 142..152

      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

      A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 13 and the first side effect is on line 3.
      Open

      <?php
      Severity: Minor
      Found in bin/resolve_chyrons.php by phpcodesniffer

      Expected 0 spaces after opening bracket; newline found
      Open

              if (
      Severity: Minor
      Found in bin/resolve_chyrons.php by phpcodesniffer

      Expected 0 spaces after opening bracket; newline found
      Open

              } elseif (
      Severity: Minor
      Found in bin/resolve_chyrons.php by phpcodesniffer

      Expected 0 spaces after opening bracket; newline found
      Open

              } elseif (
      Severity: Minor
      Found in bin/resolve_chyrons.php by phpcodesniffer

      Expected 1 space after closing brace; newline found
      Open

              }
      Severity: Minor
      Found in bin/resolve_chyrons.php by phpcodesniffer

      Expected 0 spaces after opening bracket; newline found
      Open

              } elseif (
      Severity: Minor
      Found in bin/resolve_chyrons.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status