The function get_suggestions_from_search_engine() has an NPath complexity of 348. The configured NPath complexity threshold is 200. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
Avoid unused local variables such as '$item_ref_id'. Open
foreach ($item_tool_id as $ri => $item_ref_id) {
- 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
Avoid unused local variables such as '$id'. Open
foreach ($field_val as $id => $val) {
- 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 method get_suggestions_from_search_engine uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
//no identical field id, continue as usual
$c = count($output);
if (0 == $c) {
$output[] = $row2['value'].' - ';
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method get_suggestions_from_search_engine uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($output as $i => $out) {
//use the latest combination of fields
$output[$i] .= $row2['value'].' - ';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Variable "table_sfv" is not in valid camel caps format Open
$sql = "SELECT * FROM $table_sfv where value LIKE '%$q%'".$sql_add."
- Exclude checks
Variable "current_field_val" is not in valid camel caps format Open
$current_field_val .= $val.' - ';
- Exclude checks
Variable "field_val" is not in valid camel caps format Open
$field_val = [];
- Exclude checks
Variable "field_val" is not in valid camel caps format Open
$field_val[$row2['field_id']] = $row2['value'];
- Exclude checks
Variable "more_sugg" is not in valid camel caps format Open
if (!in_array($s, $more_sugg)) {
- Exclude checks
Variable "more_sugg" is not in valid camel caps format Open
$more_sugg[] = $s;
- Exclude checks
Missing function doc comment Open
function get_suggestions_from_search_engine($q)
- Exclude checks
Variable "sql_add" is not in valid camel caps format Open
$sql_add = " AND course_code = '".$cid."' ";
- Exclude checks
Variable "more_sugg" is not in valid camel caps format Open
$more_sugg = [];
- Exclude checks
Variable "current_field_val" is not in valid camel caps format Open
$current_field_val = '';
- Exclude checks
Variable "sql_add" is not in valid camel caps format Open
$sql = "SELECT * FROM $table_sfv where value LIKE '%$q%'".$sql_add."
- Exclude checks
Variable "sql_result" is not in valid camel caps format Open
while ($row = Database::fetch_array($sql_result)) {
- Exclude checks
Variable "item_tool_id" is not in valid camel caps format Open
foreach ($item_tool_id as $ri => $item_ref_id) {
- Exclude checks
Variable "current_field_val" is not in valid camel caps format Open
$output[($c + $i)] = $current_field_val;
- Exclude checks
Variable "sql_add" is not in valid camel caps format Open
$sql_add = '';
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
foreach ($course_id as $ti => $item_tool_id) {
- Exclude checks
Variable "item_ref_id" is not in valid camel caps format Open
foreach ($item_tool_id as $ri => $item_ref_id) {
- Exclude checks
Consider putting global function "get_suggestions_from_search_engine" in a static class Open
function get_suggestions_from_search_engine($q)
- Exclude checks
Variable "field_id" is not in valid camel caps format Open
$field_id = 0;
- Exclude checks
Variable "sql_result" is not in valid camel caps format Open
$sql_result = Database::query($sql);
- Exclude checks
Variable "field_id" is not in valid camel caps format Open
$field_id = $row2['field_id'];
- Exclude checks
Variable "course_id" is not in valid camel caps format Open
foreach ($data as $cc => $course_id) {
- Exclude checks
Variable "field_val" is not in valid camel caps format Open
foreach ($field_val as $id => $val) {
- Exclude checks
Variable "item_tool_id" is not in valid camel caps format Open
foreach ($course_id as $ti => $item_tool_id) {
- Exclude checks
Variable "field_id" is not in valid camel caps format Open
if ($field_id == $row2['field_id']) {
- Exclude checks
Variable "table_sfv" is not in valid camel caps format Open
$table_sfv = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
- Exclude checks
Variable "table_sfv" is not in valid camel caps format Open
$sql2 = "SELECT * FROM $table_sfv
- Exclude checks
The variable $sql_add is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $more_sugg is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $sql_add is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $field_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $field_val is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $field_val is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $table_sfv is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $table_sfv is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $sql_add is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $field_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $sql_result is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $course_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $current_field_val is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $more_sugg is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $item_ref_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $current_field_val is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $item_tool_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $field_val is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $field_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $sql_result is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $item_tool_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $more_sugg is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $course_id is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $table_sfv is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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 $current_field_val is not named in camelCase. Open
function get_suggestions_from_search_engine($q)
{
global $charset;
$json = [];
- 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();
}
}