ernestwisniewski/kbin

View on GitHub

Showing 226 of 573 total issues

Method getMonthlyStats has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getMonthlyStats(): array
    {
        $conn = $this->getEntityManager()
            ->getConnection();

Severity: Minor
Found in src/Repository/StatsViewsRepository.php - About 1 hr to fix

    Method blurhash has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function blurhash(string $filePath): ?string
        {
            try {
                $image = imagecreatefromstring(file_get_contents($filePath));
                $width = imagesx($image);
    Severity: Minor
    Found in src/Repository/ImageRepository.php - About 1 hr to fix

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

              string $title,
              ?string $url,
              ?string $body,
              Magazine $magazine,
              User $user,
      Severity: Major
      Found in src/Entity/Entry.php - About 1 hr to fix

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

            public function findBoosts(int $page, User $user): PagerfantaInterface
            {
                // @todo union adapter
                $conn = $this->entityManager->getConnection();
                $sql = "
        Severity: Minor
        Found in src/Repository/SearchRepository.php - About 1 hr to fix

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

              public function front(?string $sortBy, ?string $time, PostRepository $repository, Request $request): Response
              {
                  $user = $this->getUser();
          
                  $criteria = new PostPageView($this->getPageNb($request));
          Severity: Minor
          Found in src/Controller/Post/PostFrontController.php - About 1 hr to fix

            Function addCommentOverview has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async addCommentOverview(data) {
                    try {
                        const parent = document.getElementById(data.detail.parentSubject.htmlId);
                        if (!parent) {
                            return;
            Severity: Minor
            Found in assets/controllers/subject_list_controller.js - About 1 hr to fix

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

                  public function search($query, int $page = 1): PagerfantaInterface
                  {
                      // @todo union adapter
                      $conn = $this->entityManager->getConnection();
                      $sql = "
              Severity: Minor
              Found in src/Repository/SearchRepository.php - About 1 hr to fix

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

                    public function getFunctions(): array
                    {
                        return [
                            new TwigFunction('entry_url', [UrlExtensionRuntime::class, 'entryUrl']),
                            new TwigFunction('entry_edit_url', [UrlExtensionRuntime::class, 'entryEditUrl']),
                Severity: Minor
                Found in src/Twig/Extension/UrlExtension.php - About 1 hr to fix

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

                      async sendForm(event) {
                          event.preventDefault();
                  
                          const form = event.target.closest('form');
                          const url = form.action;
                  Severity: Minor
                  Found in assets/controllers/subject_controller.js - 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

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

                      async handleEntries(url) {
                          let response = await fetch(url, {method: 'GET'});
                  
                          response = await ok(response);
                  
                  
                  Severity: Minor
                  Found in assets/controllers/infinite_scroll_controller.js - 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 buildResult has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function buildResult(array $result, $page, $countAll)
                      {
                          $entries = $this->entityManager->getRepository(Entry::class)->findBy(
                              ['id' => $this->getOverviewIds((array) $result, 'entry')]
                          );
                  Severity: Minor
                  Found in src/Repository/SearchRepository.php - About 1 hr to fix

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

                        public function updateMagazine(string $actorUrl): Magazine
                        {
                            $magazine = $this->magazineRepository->findOneBy(['apProfileId' => $actorUrl]);
                            $actor = $this->apHttpClient->getActorObject($actorUrl);
                    
                    
                    Severity: Minor
                    Found in src/Service/ActivityPubManager.php - About 1 hr to fix

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

                          public function getStats(
                              ?Magazine $magazine,
                              string $intervalStr,
                              ?\DateTime $start,
                              ?\DateTime $end,
                      Severity: Minor
                      Found in src/Repository/StatsContentRepository.php - About 1 hr to fix

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

                            public static function create(
                                int $id = null,
                                MagazineSmallResponseDto $magazine = null,
                                UserSmallResponseDto $user = null,
                                DomainDto $domain = null,
                        Severity: Minor
                        Found in src/Kbin/Entry/DTO/EntryResponseDto.php - About 1 hr to fix

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

                              public function getTests(): array
                              {
                                  return [
                                      new TwigTest(
                                          'entry', function ($subject) {
                          Severity: Minor
                          Found in src/Twig/Extension/SubjectExtension.php - About 1 hr to fix

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

                                #[OA\Response(
                                    response: 200,
                                    description: 'A paginated list of posts from the magazine',
                                    content: new OA\JsonContent(
                                        type: 'object',
                            Severity: Minor
                            Found in src/Controller/Api/Post/PostsRetrieveApi.php - About 1 hr to fix

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

                                  #[IsGranted('ROLE_USER')]
                                  #[IsGranted('moderate', subject: 'comment')]
                                  public function __invoke(
                                      #[MapEntity(mapping: ['magazine_name' => 'name'])]
                                      Magazine $magazine,
                              Severity: Minor
                              Found in src/Controller/Post/Comment/PostCommentModerateController.php - About 1 hr to fix

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

                                    private function getDailyStats(): array
                                    {
                                        $conn = $this->getEntityManager()
                                            ->getConnection();
                                
                                
                                Severity: Minor
                                Found in src/Repository/StatsViewsRepository.php - About 1 hr to fix

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

                                      #[IsGranted('moderate', subject: 'comment')]
                                      public function __invoke(
                                          #[MapEntity(mapping: ['magazine_name' => 'name'])]
                                          Magazine $magazine,
                                          #[MapEntity(id: 'entry_id')]
                                  Severity: Minor
                                  Found in src/Controller/Entry/Comment/EntryCommentModerateController.php - About 1 hr to fix

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

                                        public function findOrCreateFromPath(string $source): ?Image
                                        {
                                            $fileName = $this->imageManager->getFileName($source);
                                            $filePath = $this->imageManager->getFilePath($source);
                                            $sha256 = hash_file('sha256', $source, true);
                                    Severity: Minor
                                    Found in src/Repository/ImageRepository.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language