File Searchify.php
has 329 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
class Searchify extends Object
{
The class Searchify has an overall complexity of 58 which is very high. The configured complexity threshold is 50. Open
class Searchify extends Object
{
/**
* @var Indextank_Api
- Exclude checks
Method addPage
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addPage($record)
{
if (!$this->index instanceof \Indextank_Index) {
user_error(
_t(
Method addPages
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addPages($records)
{
if (!$records->count()) {
return false;
}
Method discover
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function discover($record)
{
$config = \Config::inst()->get($record->ClassName, 'db');
$content = array(
Method removePage
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function removePage($record)
{
if (!$this->index instanceof \Indextank_Index) {
user_error(
_t(
Method setIndex
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setIndex($key)
{
$indexes = $this->getIndexList();
if (!isset($indexes[$key])) {
if (!$this->config()->make_index) {
Function discover
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function discover($record)
{
$config = \Config::inst()->get($record->ClassName, 'db');
$content = array(
- 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 addPages
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function addPages($records)
{
if (!$records->count()) {
return false;
}
- 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 indexAll
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function indexAll()
{
$pages = SiteTree::get();
if (!$pages) {
- 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 '32', column '29'). Open
$this->client = new Indextank_Api($apiUrl);
- 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 unused parameters such as '$records'. Open
public function removePages(ArrayList $records)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}