Starbugstone/SnowTricks

View on GitHub

Showing 15 of 33 total issues

Method search has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search(Request $request, $categoryId = "", $slug = "")
    {
        $category = null;
        if ($categoryId !== "") {
            $category = $this->categoryRepository->find($categoryId);
Severity: Minor
Found in src/Controller/Trick/TricksByCategoryController.php - About 1 hr to fix

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

        public function showTricksByTag(Request $request, Tag $tag, string $slug)
        {
            if ($tag->getSlug() !== $slug) {
                return $this->correctSlug($tag);
            }
    Severity: Minor
    Found in src/Controller/Trick/TricksByTagController.php - About 1 hr to fix

      Function setPrimaryImage has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function setPrimaryImage(image) {
      
          let primaryImageLoader = document.querySelector('#primary-image-preloader');
          let primaryImage = document.querySelector('#trick-primary-image');
      
      
      Severity: Minor
      Found in assets/js/axiosCalls.js - About 1 hr to fix

        Function addEditForm has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Window.prototype.addEditForm =  function(e, linkElement){
            e.preventDefault();
        
            let commentId = linkElement.dataset.commentid;
            let url = linkElement.href;
        Severity: Minor
        Found in assets/js/axiosCalls.js - About 1 hr to fix

          Method searchTricks has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function searchTricks(string $query)
              {
          
                  $query = $this->sanitizeSearchQuery($query);
                  $searchTerms = $this->extractSearchTerms($query);
          Severity: Minor
          Found in src/Search/TrickSearch.php - About 1 hr to fix

            Method edit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function edit(Trick $trick, Request $request)
                {
                    $originalTrickImages = $trick->getImages()->count();
                    /** @var Form $form */
                    $form = $this->createForm(TrickFormType::class, $trick, [
            Severity: Minor
            Found in src/Controller/Trick/Admin/EditTrickController.php - About 1 hr to fix

              Method buildForm has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function buildForm(FormBuilderInterface $builder, array $options)
                  {
                      $builder
                          ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event){
                              $video = $event->getData();
              Severity: Minor
              Found in src/Form/VideoFormType.php - About 1 hr to fix

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

                    public static function getSubscribedEvents()
                    {
                        return [
                            UserRegisteredEvent::NAME => [
                                ['setPassword', 50],
                Severity: Minor
                Found in src/EventSubscriber/User/UserAccountSubscriber.php - About 1 hr to fix

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

                      public function buildForm(FormBuilderInterface $builder, array $options)
                      {
                          $builder
                              ->add('plainPassword', RepeatedType::class, [
                                  'type' => PasswordType::class,
                  Severity: Minor
                  Found in src/Form/UserChangePasswordFormType.php - About 1 hr to fix

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

                        public function show(Trick $trick, string $slug, Request $request)
                        {
                            //Checking if slug is equal to the ID. This is for SEO and external links
                            if ($trick->getSlug() !== $slug) {
                                return $this->correctSlug($trick);
                    Severity: Minor
                    Found in src/Controller/Trick/ShowTrickController.php - About 1 hr to fix

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

                          public function searchTricks(string $query)
                          {
                      
                              $query = $this->sanitizeSearchQuery($query);
                              $searchTerms = $this->extractSearchTerms($query);
                      Severity: Minor
                      Found in src/Search/TrickSearch.php - About 55 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

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

                          public function send(string $subject, string $template, $mailData, string $to, String $from = null): bool
                      Severity: Minor
                      Found in src/Mail/SendMail.php - About 35 mins to fix

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

                                TrickRepository $trickRepository,
                                CategoryRepository $categoryRepository,
                                TagRepository $tagRepository,
                                ImageRepository $imageRepository,
                                VideoRepository $videoRepository
                        Severity: Minor
                        Found in src/Search/TrickSearch.php - About 35 mins to fix

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

                              public function setPrimaryImageToggle(ImageSetPrimaryEvent $event)
                              {
                          
                                  $trick = $event->getTrick();
                                  $image = $event->getEntity();
                          Severity: Minor
                          Found in src/EventSubscriber/Image/ImageSetPrimarySubscriber.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

                          Function edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function edit(Trick $trick, Request $request)
                              {
                                  $originalTrickImages = $trick->getImages()->count();
                                  /** @var Form $form */
                                  $form = $this->createForm(TrickFormType::class, $trick, [
                          Severity: Minor
                          Found in src/Controller/Trick/Admin/EditTrickController.php - About 25 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

                          Severity
                          Category
                          Status
                          Source
                          Language