Showing 27 of 27 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function listPhonesPerPartner(
FilterRequestHandler $requestHandler,
Partner $partner,
RepresentationBuilder $representationBuilder,
Request $request,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 208.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function listClientsPerPartner(
FilterRequestHandler $requestHandler,
Partner $partner,
RepresentationBuilder $representationBuilder,
Request $request,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 208.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Partner
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class Partner implements UserInterface, JWTUserInterface
{
/**
* Define an APi admin role (associated to a partner special account).
*/
HTTPCache
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class HTTPCache
{
/**
* Define which kind of HTTP cache is used for a particular response.
*/
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function showPartner(Partner $partner, HTTPCache $httpCache): JsonResponse
{
// Find partner details
// An admin has access to all existing partners (including himself) details with this permission!
$this->denyAccessUnlessGranted(
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 129.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function showClient(Client $client, HTTPCache $httpCache): JsonResponse
{
// Check view permission (Requested client must be associated to authenticated partner.)
$this->denyAccessUnlessGranted(
ClientVoter::CAN_VIEW,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 129.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Phone
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Phone
{
/**
* Define a set of phones categories.
*/
Function loadSwaggerUI
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadSwaggerUI(userOptions = {}) {
const data = JSON.parse(document.getElementById('swagger-data').innerText);
const defaultOptions = {
spec: data.spec,
dom_id: '#swagger-ui',
Method apply
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function apply(Request $request, ParamConverter $configuration): bool
{
// Interrupt process if no uuid request attribute is found, or no special case matches!
if (null === $request->get('uuid') && !$this->setEntityUuidWithSpecialCase($request, $configuration)) {
return false;
Method loadValidatorMetadata
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function loadValidatorMetadata(ClassMetadata $metadata): void
{
$metadata->addConstraint(
new UniqueEntity([
'fields' => ['brand', 'model']
Method listClients
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listClients(
FilterRequestHandler $requestHandler,
RepresentationBuilder $representationBuilder,
Request $request,
HTTPCache $httpCache
Method listPartners
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listPartners(
FilterRequestHandler $requestHandler,
RepresentationBuilder $representationBuilder,
Request $request,
HTTPCache $httpCache
Method listOffersPerPhone
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listOffersPerPhone(
FilterRequestHandler $requestHandler,
Phone $phone,
RepresentationBuilder $representationBuilder,
Request $request,
Method loadData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadData(ObjectManager $manager): void
{
// Get existing companies sets
$data = DataProvider::PARTNER_COMPANY_SETS['references'];
// Use a row index per partner type (will be used for Proxy objects references)
Method listPhones
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listPhones(
FilterRequestHandler $requestHandler,
RepresentationBuilder $representationBuilder,
Request $request,
HTTPCache $httpCache
Method loadData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadData(ObjectManager $manager): void
{
// Get all existing phones models
$data = DataProvider::PHONE_MODELS['references'];
// Use a row index per phone brand (will be used for Proxy objects references)
Method listOffers
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listOffers(
FilterRequestHandler $requestHandler,
RepresentationBuilder $representationBuilder,
Request $request,
HTTPCache $httpCache
Function invalidateHTTPCache
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function invalidateHTTPCache(UuidInterface $entityUuid, string $className, bool $isRemoval = false): void
{
/** @var HTTPCacheRepository $httpCacheRepository */
$httpCacheRepository = $this->entityManager->getRepository(HTTPCache::class);
$results = $httpCacheRepository->findBy(['classShortName' => self::ALLOWED_ENTITIES[$className]]);
- 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 onKernelRequest
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function onKernelRequest(RequestEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
- 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
Method listPhonesPerPartner
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
FilterRequestHandler $requestHandler,
Partner $partner,
RepresentationBuilder $representationBuilder,
Request $request,
HTTPCache $httpCache