checkRequiredFields accesses the super-global variable $_POST. Open
public function checkRequiredFields(Internship $i){
$emergName = $i->getEmergencyContactName();
if(!isset($emergName)){
throw new MissingDataException("Please add an emergency contact.");
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
checkRequiredFields accesses the super-global variable $_POST. Open
public function checkRequiredFields(Internship $i){
$emergName = $i->getEmergencyContactName();
if(!isset($emergName)){
throw new MissingDataException("Please add an emergency contact.");
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
checkRequiredFields accesses the super-global variable $_POST. Open
public function checkRequiredFields(Internship $i){
$emergName = $i->getEmergencyContactName();
if(!isset($emergName)){
throw new MissingDataException("Please add an emergency contact.");
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
checkRequiredFields accesses the super-global variable $_POST. Open
public function checkRequiredFields(Internship $i){
$emergName = $i->getEmergencyContactName();
if(!isset($emergName)){
throw new MissingDataException("Please add an emergency contact.");
}
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Function allowed
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function allowed(Internship $i){
// If international and not certified by OIED, then return false
if($i->international == 1 && $i->oied_certified != 1){
return false;
}
- Read upRead up
- Create a ticketCreate a ticket
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 checkRequiredFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredFields(Internship $i){
$emergName = $i->getEmergencyContactName();
if(!isset($emergName)){
throw new MissingDataException("Please add an emergency contact.");
}
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid using static access to class '\Intern\SubHostFactory' in method 'allowed'. Open
$hostStatus = SubHostFactory:: getMainHostById($i->getHostId());
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Current_User' in method 'allowed'. Open
if(\Current_User::allow('intern', $p)){
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Call to method allow
from undeclared class \Current_User
Open
if(\Current_User::allow('intern', $p)){
- Create a ticketCreate a ticket
- Exclude checks
Avoid variables with short names like $i. Configured minimum length is 3. Open
public function allowed(Internship $i){
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
public function checkRequiredFields(Internship $i){
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Constant destState should be defined in uppercase Open
const destState = 'SigAuthApprovedState';
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}
Source https://phpmd.org/rules/naming.html#constantnamingconventions
Constant sourceState should be defined in uppercase Open
const sourceState = 'SigAuthReadyState';
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}
Source https://phpmd.org/rules/naming.html#constantnamingconventions
Constant actionName should be defined in uppercase Open
const actionName = 'Approved by Signature Authority';
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
ConstantNamingConventions
Since: 0.2
Class/Interface constant names should always be defined in uppercase.
Example
class Foo {
const MY_NUM = 0; // ok
const myTest = ""; // fail
}