Showing 1,422 of 1,422 total issues

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

$app->get('/events/:id/forum_links/:forum_link', function($id, $forum_link) use ($app) {
    header("Content-Type: application/json");
    $forum_link = Links::get_forum_link($img); //need to find this function
    if ($forum_link["status"] == Links::ERROR) {
        $app->response->status(404);
Severity: Major
Found in features/links/routes.php and 3 other locations - About 45 mins to fix
features/images/routes.php on lines 34..44
features/irc/routes.php on lines 34..44
features/jira/routes.php on lines 38..48

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

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

$app->get('/events/:id/images/:img', function($id, $img) use ($app) {
    header("Content-Type: application/json");
    $image = Images::get_image($img);
    if ($image["status"] == Images::ERROR) {
        $app->response->status(404);
Severity: Major
Found in features/images/routes.php and 3 other locations - About 45 mins to fix
features/irc/routes.php on lines 34..44
features/jira/routes.php on lines 38..48
features/links/routes.php on lines 36..45

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

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

<?php

$app->get('/events/:id/why_surprised', function($id) use ($app) {
        $event = Postmortem::get_event($id);
        
Severity: Minor
Found in features/why_surprised/routes.php and 1 other location - About 45 mins to fix
features/tldr/routes.php on lines 1..12

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

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

$app->get('/events/:id/channels/:channel', function($id, $channel) use ($app) {
    header("Content-Type: application/json");
    $chan = Irc::get_channel($channel);
    if ($chan["status"] == Irc::ERROR) {
        $app->response->status(404);
Severity: Major
Found in features/irc/routes.php and 3 other locations - About 45 mins to fix
features/images/routes.php on lines 34..44
features/jira/routes.php on lines 38..48
features/links/routes.php on lines 36..45

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

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

    static function store_array($table_name, $assoc_column, $values, $postmortem_id, $conn) {
        try {
            foreach ($values as $value) {
                $select_sql = 'SELECT postmortem_id, id, deleted ' .
                              ' FROM ' . $table_name .
Severity: Minor
Found in phplib/Persistence.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

Each class must be in a file by itself
Open

class JiraClient {
Severity: Minor
Found in features/jira/lib.php by phpcodesniffer

Function get_channel_data has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function get_channel_data(url, params, channels, success_callback, error_callback) {
Severity: Minor
Found in htdocs/assets/js/irc.js - About 35 mins to fix

    Method get has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        function get($url, array $params = null, $user_pass = null, $proxy = null,
                     $timeout = 10) {
    Severity: Minor
    Found in phplib/CurlClient.php - About 35 mins to fix

      Function confirm_delete has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function confirm_delete(message, insert, context, onConfirm, onDisappear) {
      Severity: Minor
      Found in htdocs/assets/js/api.js - About 35 mins to fix

        Method store_array has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            static function store_array($table_name, $assoc_column, $values, $postmortem_id, $conn) {
        Severity: Minor
        Found in phplib/Persistence.php - About 35 mins to fix

          Method name "ContactTest::test_getUrlForUser_lookupDefined" is not in camel caps format
          Open

              public function test_getUrlForUser_lookupDefined() {
          Severity: Minor
          Found in tests/unit/Contact_Test.php by phpcodesniffer

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

              static function delete_tag($tag_id, $event_id = null, $conn = null) {
                  $conn = $conn ?: Persistence::get_database_object();
                  if (is_null($conn)) {
                      return array("status" => self::ERROR,
                          "error" => "Couldn't get connection object.");
          Severity: Minor
          Found in phplib/Postmortem.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

          Opening brace of a class must be on the line after the definition
          Open

          class ContactTest extends \PHPUnit\Framework\TestCase {
          Severity: Minor
          Found in tests/unit/Contact_Test.php by phpcodesniffer

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

              static function get_configuration($name = null) {
                  $enviroment = getenv('MORGUE_ENVIRONMENT') ?: 'development';
                  $configfile = dirname(__FILE__).'/../config/'.$enviroment.'.json';
                  $config = json_decode(file_get_contents($configfile), true);
                  if (is_null($name)) {
          Severity: Minor
          Found in phplib/Configuration.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

          Method name "ContactTest::test_getHtmlForUser_lookupDefined" is not in camel caps format
          Open

              public function test_getHtmlForUser_lookupDefined() {
          Severity: Minor
          Found in tests/unit/Contact_Test.php by phpcodesniffer

          Method name "ContactTest::test_getUrlForUser_nolookupDefined" is not in camel caps format
          Open

              public function test_getUrlForUser_nolookupDefined() {
          Severity: Minor
          Found in tests/unit/Contact_Test.php by phpcodesniffer

          Method name "ContactTest::test_getHtmlForUser_nolookupDefined" is not in camel caps format
          Open

              public function test_getHtmlForUser_nolookupDefined() {
          Severity: Minor
          Found in tests/unit/Contact_Test.php by phpcodesniffer

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

              static function undelete_tag($tag_id, $event_id = null, $conn = null) {
                  $conn = $conn ?: Persistence::get_database_object();
                  if (is_null($conn)) {
                      return array("status" => self::ERROR,
                          "error" => "Couldn't get connection object.");
          Severity: Minor
          Found in phplib/Postmortem.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 get_slack_channels_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              function get_slack_channels_list() {
                  if (function_exists("morgue_get_slack_channels_list")) {
                      return morgue_get_slack_channels_list();
                  } else {
                      $queryParam = array(
          Severity: Minor
          Found in features/slack/lib.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

          Opening brace of a class must be on the line after the definition
          Open

          class CurlClientTest extends \PHPUnit\Framework\TestCase {
          Severity
          Category
          Status
          Source
          Language