codeclimate/codeclimate-sonar-php

View on GitHub
src/test/resources/sanity_check_expected_issues.json

Summary

Maintainability
Test Coverage
[
  {
    "type": "issue",
    "check_name": "php:S108",
    "severity": "major",
    "description": "Either remove or fill this block of code.",
    "content": {
      "body": "<p>Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.</p>\n<h2>Noncompliant Code Example</h2>\n<pre>\nfor ($i = 0; $i &lt; 42; $i++){}  // Empty on purpose or missing piece of code ?\n</pre>\n<h2>Exceptions</h2>\n<p>When a block contains a comment, this block is not considered to be empty.</p>"
    },
    "location": {
      "path": "main.php",
      "lines": {
        "begin": 7,
        "end": 8
      }
    },
    "categories": [
      "Bug Risk"
    ]
  },
  {
    "type": "issue",
    "check_name": "php:S2014",
    "severity": "blocker",
    "description": "Remove this use of \"$this\".",
    "content": {
      "body": "<p><code>$this</code> refers to the current class instance. But static methods can be accessed without instantiating the class, and <code>$this</code>\nis not available to them. Using <code>$this</code> in a static context will result in a fatal error at runtime.</p>\n<h2>Noncompliant Code Example</h2>\n<pre>\nclass Clazz {\n  $name=NULL;  // instance variable\n\n  public static function foo(){\n    if ($this-&gt;name != NULL) {\n      // ...\n    }\n  }\n}\n</pre>\n<h2>Compliant Solution</h2>\n<pre>\nclass Clazz {\n  $name=NULL;  // instance variable\n\n  public static function foo($nameParam){\n    if ($nameParam != NULL) {\n      // ...\n    }\n  }\n}\n</pre>"
    },
    "location": {
      "path": "main.php",
      "lines": {
        "begin": 7,
        "end": 7
      }
    },
    "categories": [
      "Bug Risk"
    ]
  },
  {
    "type": "issue",
    "check_name": "php:S1068",
    "severity": "major",
    "description": "Remove this unused \"PRIVATE_CONST\" private field.",
    "content": {
      "body": "<p>If a <code>private</code> field is declared but not used in the program, it can be considered dead code and should therefore be removed. This will\nimprove maintainability because developers will not wonder what the variable is used for.</p>\n<h2>Noncompliant Code Example</h2>\n<pre>\nclass MyClass {\n  private $foo = 4;                       //foo is unused\n\n  public function compute($a) {\n    return $a * 4;\n  }\n}\n</pre>\n<h2>Compliant Solution</h2>\n<pre>\nclass MyClass {\n\n  public function compute($a) {\n    return $a * 4;\n  }\n}\n</pre>\n<h2>See</h2>\n<ul>\n  <li> <a href=\"https://www.securecoding.cert.org/confluence/x/SIIyAQ\">CERT, MSC12-CPP.</a> - Detect and remove code that has no effect </li>\n</ul>"
    },
    "location": {
      "path": "php7_constants.php",
      "lines": {
        "begin": 7,
        "end": 7
      }
    },
    "categories": [
      "Clarity"
    ]
  }
]