Covivo/mobicoop

View on GitHub
api/src/Image/Service/ImageManager.php

Summary

Maintainability
D
1 day
Test Coverage

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case Badge::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/badges/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the Badge n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 536..543
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case Editorial::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/editorials/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the Editorial n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case RelayPoint::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/relaypoints/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the RelayPoint n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 536..543
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case Structure::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/structures/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the Structure n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 536..543

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case Campaign::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/masscommunication/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the Campaign n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 536..543
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case Event::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/events/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the Event n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 536..543
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case User::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/users/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the User n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 491..498
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 536..543
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

                case Community::class:
                    if (!file_exists(dirname(__FILE__).'/../../../public/upload/communities/images/'.$image->getFileName())) {
                        $this->loggerMaintenance->info('ImageManager : remove image '.$image->getFileName().' without associated file of the Community n°'.$owner->getId().' .'.(new \DateTime('UTC'))->format('Ymd H:i:s.u'));
                        $this->deleteVersions($image);
                        $this->deleteBase($image, false);
Severity: Major
Found in api/src/Image/Service/ImageManager.php and 7 other locations - About 1 hr to fix
api/src/Image/Service/ImageManager.php on lines 482..489
api/src/Image/Service/ImageManager.php on lines 500..507
api/src/Image/Service/ImageManager.php on lines 509..516
api/src/Image/Service/ImageManager.php on lines 518..525
api/src/Image/Service/ImageManager.php on lines 527..534
api/src/Image/Service/ImageManager.php on lines 536..543
api/src/Image/Service/ImageManager.php on lines 545..552

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 114.

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

Further Reading

There are no issues that match your filters.

Category
Status