Showing 108 of 108 total issues
Function filterProperty
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
{
if (
null === $value
|| !$this->isPropertyEnabled($property, $resourceClass)
- 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 create
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function create(string $resourceClass): ResourceMetadataCollection
{
$resourceMetadata = $this->decorated->create($resourceClass);
if (!$this->uploadableFileManager->isConfigured($resourceClass)) {
return $resourceMetadata;
- 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 buildForm
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add(
'username',
Method onPostRespond
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onPostRespond(ResponseEvent $event): void
{
$request = $event->getRequest();
$attributes = $this->getAttributes($request);
Method buildForm
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var UserInterface|null $user */
$user = $builder->getEmptyData();
Method createEmailMessage
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function createEmailMessage(array $context = []): ?TemplatedEmail
{
if (!$this->enabled) {
return null;
}
Function denormalize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function denormalize($data, $type, $format = null, array $context = []): mixed
{
$context[self::ALREADY_CALLED] = true;
foreach ($data as $fieldName => $value) {
- 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 create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function create(string $resourceClass): ResourceMetadataCollection
{
$resourceMetadata = $this->decorated->create($resourceClass);
$refl = new \ReflectionClass($resourceClass);
- 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 create
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create(string $resourceClass): ResourceMetadataCollection
{
$resourceMetadata = $this->decorated->create($resourceClass);
if (!$this->uploadableFileManager->isConfigured($resourceClass)) {
return $resourceMetadata;
Method __invoke
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke(?object $data, Request $request, UploadableFileManager $uploadableFileManager, PublishableStatusChecker $publishableStatusChecker)
{
$contentType = $request->headers->get('CONTENT_TYPE');
if (null === $contentType) {
throw new UnsupportedMediaTypeHttpException('The "Content-Type" header must exist.');
Method setMailerServiceArguments
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function setMailerServiceArguments(ContainerBuilder $container, array $config): void
{
$definition = $container->getDefinition(UserMailer::class);
$definition->setArgument(
'$context',
Similar blocks of code found in 2 locations. Consider refactoring. Open
$services
->set(UploadableEventListener::class)
->args(
[
new Reference(UploadableAttributeReader::class),
- 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 107.
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
$services
->set(UserEventListener::class)
->args(
[
new Reference(UserMailer::class),
- 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 107.
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
Method addWhereByStrategy
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $value, bool $caseSensitive): void
{
$wrapCase = $this->createWrapCase($caseSensitive);
$valueParameter = $queryNameGenerator->generateParameterName($field);
switch ($strategy) {
Function loadClassMetadata
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
{
$reflectionClass = $classMetadata->getReflectionClass();
$reflectionClassName = $reflectionClass->getName();
if (
- 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 transform
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function transform(Collection $object): Collection
{
$parameters = $this->resourceRouteFinder->findByIri($object->getResourceIri());
$attributes = AttributesExtractor::extractAttributes($parameters);
$request = $this->requestStack->getMainRequest();
- 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 findGetCollectionOperation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function findGetCollectionOperation(string $resourceClass): ?HttpOperation
{
$metadata = $this->resourceMetadataCollectionFactory->create($resourceClass);
$it = $metadata->getIterator();
/** @var ApiResource $apiResource */
- 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 remove
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function remove(array $paths, array $filters): void
{
if (empty($paths) && empty($filters)) {
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
Function __invoke
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function __invoke(?object $data, Request $request, UploadableFileManager $uploadableFileManager, PublishableStatusChecker $publishableStatusChecker)
{
$contentType = $request->headers->get('CONTENT_TYPE');
if (null === $contentType) {
throw new UnsupportedMediaTypeHttpException('The "Content-Type" header must exist.');
- 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 __invoke
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __invoke(FormSuccessEvent $event): void
{
// This is not a sub-request because forms have greater permissions to create entitites with whatever properties wanted.
if (