Method _resolvePathSpec
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _resolvePathSpec($paths)
{
$resolved = array();
// Strings treaded as file patterns, but existing file paths treated literally
Function _resolvePathSpec
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _resolvePathSpec($paths)
{
$resolved = array();
// Strings treaded as file patterns, but existing file paths treated literally
- Read upRead up
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 _getFilePaths
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
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
Missing class import via use statement (line '163', column '23'). Open
throw new \RuntimeException(sprintf('Could not retrieve class name: cannot read file "%1$s"', $path));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid assigning values to variables in if clauses and the like (line '134', column '15'). Open
protected function _getFileTests($path)
{
if (!($className = $this->_retrieveFileClassName($path))) {
return array();
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid unused local variables such as '$_misc'. Open
foreach ($paths as $_path => $_misc) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The variable $_path is not named in camelCase. Open
public function locate()
{
$items = array();
foreach ($this->_getFilePaths() as $_path) {
$tests = $this->_getFileTests($_path);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_path is not named in camelCase. Open
protected function _resolvePathSpec($paths)
{
$resolved = array();
// Strings treaded as file patterns, but existing file paths treated literally
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_misc is not named in camelCase. Open
protected function _resolvePathSpec($paths)
{
$resolved = array();
// Strings treaded as file patterns, but existing file paths treated literally
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_key is not named in camelCase. Open
public function _arrayMerge($array, $traversable)
{
foreach ($traversable as $_key => $_value) {
$array[$_key] = $_value;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_path is not named in camelCase. Open
protected function _resolvePathSpec($paths)
{
$resolved = array();
// Strings treaded as file patterns, but existing file paths treated literally
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_pathExpr is not named in camelCase. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_path is not named in camelCase. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_key is not named in camelCase. Open
public function _arrayMerge($array, $traversable)
{
foreach ($traversable as $_key => $_value) {
$array[$_key] = $_value;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_value is not named in camelCase. Open
public function _arrayMerge($array, $traversable)
{
foreach ($traversable as $_key => $_value) {
$array[$_key] = $_value;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_pathExpr is not named in camelCase. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_path is not named in camelCase. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_value is not named in camelCase. Open
public function _arrayMerge($array, $traversable)
{
foreach ($traversable as $_key => $_value) {
$array[$_key] = $_value;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_path is not named in camelCase. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_path is not named in camelCase. Open
public function locate()
{
$items = array();
foreach ($this->_getFilePaths() as $_path) {
$tests = $this->_getFileTests($_path);
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The method _createClassLocator is not named in camelCase. Open
abstract protected function _createClassLocator($className);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _basename is not named in camelCase. Open
protected function _basename($fileName)
{
$basename = basename($fileName);
$basename = explode('.', $basename);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _resolvePathSpec is not named in camelCase. Open
protected function _resolvePathSpec($paths)
{
$resolved = array();
// Strings treaded as file patterns, but existing file paths treated literally
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _getPathsSpecs is not named in camelCase. Open
protected function _getPathsSpecs()
{
return $this->pathSpecs;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _matchFile is not named in camelCase. Open
abstract protected function _matchFile($file);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _endsWith is not named in camelCase. Open
protected function _endsWith($string, $requiredSuffix)
{
$requiredLength = strlen($requiredSuffix);
$suffix = substr($string, -$requiredLength, $requiredLength);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _normalizePath is not named in camelCase. Open
protected function _normalizePath($path)
{
$path = trim($path);
$path = str_replace('\\/', DIRECTORY_SEPARATOR, $path);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _hashPath is not named in camelCase. Open
protected function _hashPath($path)
{
return $this->_hash($path);
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _getFileTests is not named in camelCase. Open
protected function _getFileTests($path)
{
if (!($className = $this->_retrieveFileClassName($path))) {
return array();
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _retrieveFileClassName is not named in camelCase. Open
protected function _retrieveFileClassName($path)
{
$basename = $this->_basename($path);
if (!is_readable($path)) {
throw new \RuntimeException(sprintf('Could not retrieve class name: cannot read file "%1$s"', $path));
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _getFilePaths is not named in camelCase. Open
protected function _getFilePaths()
{
$results = array();
foreach ($this->_getPathsSpecs() as $_pathExpr) {
$paths = $this->_resolvePathSpec($_pathExpr);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method _arrayMerge is not named in camelCase. Open
public function _arrayMerge($array, $traversable)
{
foreach ($traversable as $_key => $_value) {
$array[$_key] = $_value;
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}