harentius/blog-bundle

View on GitHub

Showing 21 of 21 total issues

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

    private function createArchiveController(Environment $twig, SlidingPagination $slidingPagination): ArchiveController
    {
        $articleRepository = $this->createMock(ArticleRepository::class);
        $breadCrumbsManager = $this->createMock(BreadCrumbsManager::class);
        $knpPaginator = $this->createMock(PaginatorInterface::class);
Severity: Major
Found in tests/Unit/Controller/ArchiveControllerTest.php and 1 other location - About 3 hrs to fix
tests/Unit/Controller/TagControllerTest.php on lines 46..63

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

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 2 locations. Consider refactoring.
Open

    private function createTagController(Environment $twig, SlidingPagination $slidingPagination): TagController
    {
        $articleRepository = $this->createMock(ArticleRepository::class);
        $breadCrumbsManager = $this->createMock(BreadCrumbsManager::class);
        $knpPaginator = $this->createMock(PaginatorInterface::class);
Severity: Major
Found in tests/Unit/Controller/TagControllerTest.php and 1 other location - About 3 hrs to fix
tests/Unit/Controller/ArchiveControllerTest.php on lines 46..64

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

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

Method getConfigTreeBuilder has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('harentius_blog');
        $rootNode = $treeBuilder->getRootNode();

Severity: Minor
Found in src/DependencyInjection/Configuration.php - About 1 hr to fix

    Method handleUpload has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handleUpload(UploadedFile $uploadedFile = null, array $options = [])
        {
            $resolver = new OptionsResolver();
            $resolver
                ->setDefaults([
    Severity: Minor
    Found in src/FileManagement/FileManager.php - About 1 hr to fix

      Method configureFormFields has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function configureFormFields(FormMapper $formMapper)
          {
              $formMapper
                  ->add('title')
                  ->add('slug', null, [
      Severity: Minor
      Found in src/Admin/Admin/ArticleAdmin.php - About 1 hr to fix

        Method createAdmin has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function createAdmin(string $class): AbstractAdmin
            {
                if (!is_subclass_of($class, AbstractAdmin::class)) {
                    throw new \InvalidArgumentException("Class '{$class}' is not subclass of 'AbstractAdmin'");
                }
        Severity: Minor
        Found in test/SonataAdminClassTestCase.php - About 1 hr to fix

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

              public function testInvokeWithPage(): void
              {
                  $page = new Page();
                  $twig = $this->createMock(Environment::class);
                  $twig
          Severity: Major
          Found in tests/Unit/Controller/ShowControllerTest.php and 1 other location - About 1 hr to fix
          tests/Unit/Controller/ShowControllerTest.php on lines 18..32

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

          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 2 locations. Consider refactoring.
          Open

              public function testInvokeWithArticle(): void
              {
                  $article = new Article();
                  $twig = $this->createMock(Environment::class);
                  $twig
          Severity: Major
          Found in tests/Unit/Controller/ShowControllerTest.php and 1 other location - About 1 hr to fix
          tests/Unit/Controller/ShowControllerTest.php on lines 34..48

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

          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

          Function setFile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function setFile(File $value = null, $fallbackType = null)
              {
                  $this->file = $value;
          
                  if ($this->file === null) {
          Severity: Minor
          Found in src/FileManagement/AssetFile.php - About 1 hr to fix

          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 notEmptyChildrenHierarchy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function notEmptyChildrenHierarchy(array $options = [])
              {
                  /** @var Query $q1 */
                  $q1 = $this->createQueryBuilder('cc')
                      ->where('cc.left >= c.left')
          Severity: Minor
          Found in src/Entity/CategoryRepository.php - About 1 hr to fix

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

                protected function configureFormFields(FormMapper $formMapper)
                {
                    $formMapper
                        ->add('title')
                        ->add('slug', null, [
            Severity: Minor
            Found in src/Admin/Admin/PageAdmin.php - About 1 hr to fix

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

                  public function testBuildPage(): void
                  {
                      /** @var Breadcrumbs|SingleBreadcrumb[] $breadCrumbs */
                      $breadCrumbs = new Breadcrumbs();
                      $breadCrumbsManager = $this->createBreadCrumbsManager($breadCrumbs);
              Severity: Minor
              Found in tests/Unit/BreadCrumbsManagerTest.php and 2 other locations - About 40 mins to fix
              tests/Unit/BreadCrumbsManagerTest.php on lines 19..31
              tests/Unit/BreadCrumbsManagerTest.php on lines 55..67

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

              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 3 locations. Consider refactoring.
              Open

                  public function testBuildCategory(): void
                  {
                      /** @var Breadcrumbs|SingleBreadcrumb[] $breadCrumbs */
                      $breadCrumbs = new Breadcrumbs();
                      $breadCrumbsManager = $this->createBreadCrumbsManager($breadCrumbs);
              Severity: Minor
              Found in tests/Unit/BreadCrumbsManagerTest.php and 2 other locations - About 40 mins to fix
              tests/Unit/BreadCrumbsManagerTest.php on lines 55..67
              tests/Unit/BreadCrumbsManagerTest.php on lines 103..116

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

              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 3 locations. Consider refactoring.
              Open

                  public function testBuildTag(): void
                  {
                      /** @var Breadcrumbs|SingleBreadcrumb[] $breadCrumbs */
                      $breadCrumbs = new Breadcrumbs();
                      $breadCrumbsManager = $this->createBreadCrumbsManager($breadCrumbs);
              Severity: Minor
              Found in tests/Unit/BreadCrumbsManagerTest.php and 2 other locations - About 40 mins to fix
              tests/Unit/BreadCrumbsManagerTest.php on lines 19..31
              tests/Unit/BreadCrumbsManagerTest.php on lines 103..116

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

              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

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

                      FactoryInterface $factory,
                      PageRepository $pageRepository,
                      PublicationUrlGenerator $publicationUrlGenerator,
                      RequestStack $requestStack,
                      ?string $homepageSlug
              Severity: Minor
              Found in src/Menu/MenuBuilder.php - About 35 mins to fix

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

                        CacheManager $cacheManager,
                        FilterManager $filterManager,
                        DataManager $dataManager,
                        FilePathResolver $assetsResolver,
                        $targetBasePath
                Severity: Minor
                Found in src/FileManagement/Image/ImageOptimizer.php - About 35 mins to fix

                  Function getList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getList()
                      {
                          $tags = $this->tagRepository->findMostPopularLimited($this->sidebarTagsLimit);
                  
                          if (!$tags) {
                  Severity: Minor
                  Found in src/Sidebar/Tags.php - About 35 mins to fix

                  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

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

                      public function testTags(): void
                      {
                          $twig = $this->createMock(Environment::class);
                          $twig
                              ->expects($this->once())
                  Severity: Minor
                  Found in tests/Unit/Controller/SidebarControllerTest.php and 2 other locations - About 30 mins to fix
                  tests/Unit/Controller/SidebarControllerTest.php on lines 18..31
                  tests/Unit/Controller/SidebarControllerTest.php on lines 33..46

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

                  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 3 locations. Consider refactoring.
                  Open

                      public function testArchive(): void
                      {
                          $twig = $this->createMock(Environment::class);
                          $twig
                              ->expects($this->once())
                  Severity: Minor
                  Found in tests/Unit/Controller/SidebarControllerTest.php and 2 other locations - About 30 mins to fix
                  tests/Unit/Controller/SidebarControllerTest.php on lines 18..31
                  tests/Unit/Controller/SidebarControllerTest.php on lines 48..61

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

                  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 3 locations. Consider refactoring.
                  Open

                      public function testCategories(): void
                      {
                          $twig = $this->createMock(Environment::class);
                          $twig
                              ->expects($this->once())
                  Severity: Minor
                  Found in tests/Unit/Controller/SidebarControllerTest.php and 2 other locations - About 30 mins to fix
                  tests/Unit/Controller/SidebarControllerTest.php on lines 33..46
                  tests/Unit/Controller/SidebarControllerTest.php on lines 48..61

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language