Showing 226 of 573 total issues
Method serializeNotification
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function serializeNotification(Notification $dto)
{
$toReturn = [
'notificationId' => $dto->getId(),
'status' => $dto->status,
Method findByObjectId
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function findByObjectId(string $apId): ?array
{
$parsed = parse_url($apId);
if ($parsed['host'] === $this->settingsManager->get('KBIN_DOMAIN')) {
$exploded = array_filter(explode('/', $parsed['path']));
File PostCommentsRetrieveApi.php
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only
Method findPeople
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function findPeople(Magazine $magazine, ?bool $federated = false, $limit = 200): array
{
$conn = $this->_em->getConnection();
$sql = '
(SELECT count(id), user_id FROM entry WHERE magazine_id = :magazineId GROUP BY user_id ORDER BY count DESC LIMIT 50)
Method __construct
has 17 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private Server $server,
private UserRepository $userRepository,
private UserCreate $userCreate,
private UserFactory $userFactory,
private MagazineCreate $magazineCreate,
Method __invoke
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __invoke(
#[MapEntity(mapping: ['magazine_name' => 'name'])]
Magazine $magazine,
#[MapEntity(id: 'entry_id')]
Entry $entry,
File NotificationReadApi.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only
Method __invoke
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __invoke(
#[MapEntity(mapping: ['magazine_name' => 'name'])]
Magazine $magazine,
#[MapEntity(id: 'post_id')]
Post $post,
File StatsContentRepository.php
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only
Method __invoke
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
#[OA\Response(
response: 201,
description: 'Returns the created oauth2 client. Be sure to save the identifier and secret since these will be how you obtain tokens for the API.',
content: new Model(type: OAuth2ClientDto::class, groups: ['created', 'common']),
headers: [
Method findActorOrCreate
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function findActorOrCreate(string $actorUrlOrHandle): null|User|Magazine
{
if (str_contains($actorUrlOrHandle, $this->settingsManager->get('KBIN_DOMAIN').'/m/')) {
$magazine = str_replace('https://'.$this->settingsManager->get('KBIN_DOMAIN').'/m/', '', $actorUrlOrHandle);
Method findByApId
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function findByApId($url): array
{
// @todo union adapter
$conn = $this->entityManager->getConnection();
$sql = "
Method aggregateTotalStats
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function aggregateTotalStats(?Magazine $magazine): array
{
$conn = $this->getEntityManager()->getConnection();
$results = [];
Function sendForm
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async sendForm(event) {
event.preventDefault();
const form = event.target.closest('form');
const url = form.action;
Function findPeople
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
public function findPeople(Magazine $magazine, ?bool $federated = false, $limit = 200): array
{
$conn = $this->_em->getConnection();
$sql = '
(SELECT count(id), user_id FROM entry WHERE magazine_id = :magazineId GROUP BY user_id ORDER BY count DESC LIMIT 50)
- 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 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
#[OA\Response(
response: 200,
description: 'Returns a paginated list of content, along with any ActivityPub actors that matched the query by username, or ActivityPub objects that matched the query by URL. Actors and objects are not paginated',
content: new OA\JsonContent(
type: 'object',
Method uploadImage
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
#[OA\Response(
response: 201,
description: 'Returns the created oauth2 client. Be sure to save the identifier and secret since these will be how you obtain tokens for the API.',
content: new Model(type: OAuth2ClientDto::class, groups: ['Default', 'created', 'common']),
headers: [
Method up
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("INSERT INTO \"public\".\"award_type\" (\"id\", \"name\", \"category\", \"count\", \"attributes\") VALUES
(1, 'bronze_autobiographer', 'bronze', 0, 'a:0:{}'),
Method jsonSerialize
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function jsonSerialize(): mixed
{
if (null === self::$keysToDelete) {
self::$keysToDelete = [
'domain',
Method filter
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function filter(QueryBuilder $qb, Criteria $criteria): void
{
if ($criteria->post) {
$qb->andWhere('c.post = :post')
->setParameter('post', $criteria->post);