Invis1ble/assistant

View on GitHub

Showing 56 of 56 total issues

Method testPostCategory has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function testPostCategory()
{
$uuid4 = $this->getUUID4stub();
 
$alice = $this->getUser('alice');
Severity: Minor
Found in tests/AppBundle/Controller/UserCategoryControllerTest.php - About 1 hr to fix

Method testRoles has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function testRoles()
{
$user = new User();
 
$this->assertSame([User::ROLE_DEFAULT], $user->getRoles());
Severity: Minor
Found in tests/AppBundle/Entity/UserTest.php - About 1 hr to fix

Method voteOnAttribute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

protected function voteOnAttribute($attribute, $category, TokenInterface $token)
{
$user = $token->getUser();
 
if (!$user instanceof UserInterface) {
Severity: Minor
Found in src/AppBundle/Security/Authorization/Voter/CategoryVoter.php - About 1 hr to fix

Function validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

public function validate($period, Constraint $constraint)
{
if (!$constraint instanceof PeriodIsCoherent) {
throw new UnexpectedTypeException($constraint, PeriodIsCoherent::class);
}
Severity: Minor
Found in src/AppBundle/Validator/Constraints/PeriodIsCoherentValidator.php - About 55 mins to fix

Avoid variables with short names like $id. Configured minimum length is 3.
Open

public function setId(string $id)
Severity: Minor
Found in src/AppBundle/Entity/User.php by phpmd

Function voteOnAttribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

protected function voteOnAttribute($attribute, $category, TokenInterface $token)
{
$user = $token->getUser();
 
if (!$user instanceof UserInterface) {
Severity: Minor
Found in src/AppBundle/Security/Authorization/Voter/CategoryVoter.php - About 45 mins to fix

Function voteOnAttribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

protected function voteOnAttribute($attribute, $task, TokenInterface $token)
{
$user = $token->getUser();
 
if (!$user instanceof UserInterface) {
Severity: Minor
Found in src/AppBundle/Security/Authorization/Voter/TaskVoter.php - About 45 mins to fix

Method createView has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

protected function createView(\Exception $exception, $code, array $templateData, Request $request, $showException)
Severity: Minor
Found in src/AppBundle/Controller/ExceptionController.php - About 35 mins to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

protected function supports($attribute, $subject)
{
$attribute = strtolower($attribute);
 
if (!in_array($attribute, [
Severity: Minor
Found in src/AppBundle/Security/Authorization/Voter/CategoryVoter.php and 1 other location - About 35 mins to fix
src/AppBundle/Security/Authorization/Voter/TaskVoter.php on lines 32..49

Identical blocks of code found in 2 locations. Consider refactoring.
Open

protected function supports($attribute, $subject)
{
$attribute = strtolower($attribute);
 
if (!in_array($attribute, [
Severity: Minor
Found in src/AppBundle/Security/Authorization/Voter/TaskVoter.php and 1 other location - About 35 mins to fix
src/AppBundle/Security/Authorization/Voter/CategoryVoter.php on lines 32..49

Missing class import via use statement (line '52', column '31').
Open

[$aliceToken, new \stdClass(), TaskVoter::DELETE, TaskVoter::ACCESS_ABSTAIN],

Missing class import via use statement (line '42', column '31').
Open

[$aliceToken, new \stdClass(), CategoryTaskVoter::LIST, CategoryTaskVoter::ACCESS_ABSTAIN],

Missing class import via use statement (line '47', column '31').
Open

[$aliceToken, new \stdClass(), TaskPeriodVoter::CREATE, TaskPeriodVoter::ACCESS_ABSTAIN],

Missing class import via use statement (line '37', column '31').
Open

[$aliceToken, new \stdClass(), UserCategoryVoter::LIST, UserCategoryVoter::ACCESS_ABSTAIN],

Missing class import via use statement (line '47', column '31').
Open

[$aliceToken, new \stdClass(), CategoryVoter::EDIT, CategoryVoter::ACCESS_ABSTAIN],

Missing class import via use statement (line '50', column '31').
Open

[$aliceToken, new \stdClass(), PeriodVoter::EDIT, PeriodVoter::ACCESS_ABSTAIN],

The method request has a boolean flag argument $changeHistory, which is a certain sign of a Single Responsibility Principle violation.
Open

bool $changeHistory = true,

Avoid too many return statements within this method.
Open

return false;
Severity: Major
Found in src/AppBundle/Security/Authorization/Voter/TaskVoter.php - About 30 mins to fix

Missing class import via use statement (line '42', column '31').
Open

[$aliceToken, new \stdClass(), TaskVoter::SHOW, TaskVoter::ACCESS_ABSTAIN],

Missing class import via use statement (line '42', column '31').
Open

[$aliceToken, new \stdClass(), UserCategoryVoter::CREATE, UserCategoryVoter::ACCESS_ABSTAIN],
Severity
Category
Status
Source
Language