Skip to content

Commit

Permalink
BB-15559: Make PHPMD settings same for all packages (#28627)
Browse files Browse the repository at this point in the history
- Updated Jenkinsfile and php_code_style_standalone.sh to run a single combined PHP codestyle build.
- Updated platform/build/phpmd.xml to use PHPMD defaults and removed phpmd.xml in other packages.
- Suppressed PHPMD.CyclomaticComplexity, PHPMD.TooManyPublicMethods, PHPMD.TooManyMethods, PHPMD.TooManyFields in existing code.
  • Loading branch information
mbessolov authored Aug 27, 2020
1 parent cf8315e commit 67d67db
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions Entity/Recurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ public function getTimeZone()
*
* @param Recurrence|null $other
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function isEqual($other)
{
Expand Down
5 changes: 5 additions & 0 deletions Form/EventListener/AttendeesSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

/**
* Makes sure indexes of attendees from request are equal to indexes of the same
* attendees so that in the end we end up with correct data.
*/
class AttendeesSubscriber implements EventSubscriberInterface
{
/**
Expand All @@ -26,6 +30,7 @@ public static function getSubscribedEvents()
* Makes sure indexes of attendees from request are equal to indexes of the same
* attendees so that in the end we end up with correct data.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @param FormEvent $event
*/
public function fixSubmittedData(FormEvent $event)
Expand Down
5 changes: 4 additions & 1 deletion Form/Handler/CalendarEventApiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
use Oro\Bundle\CalendarBundle\Entity\CalendarEvent;
use Oro\Bundle\CalendarBundle\Manager\CalendarEvent\NotificationManager;

/**
* Form handler for calendar event form, used in legacy REST API.
*/
class CalendarEventApiHandler extends AbstractCalendarEventHandler
{
/**
* Process form
*
* @param CalendarEvent $entity
* @return bool True on successful processing, false otherwise
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function process(CalendarEvent $entity)
{
Expand All @@ -26,7 +30,6 @@ public function process(CalendarEvent $entity)
$this->form->submit($request->request->all());

if ($this->form->isValid()) {
// TODO: should be refactored after finishing BAP-8722
// Contexts handling should be moved to common for activities form handler
if ($this->form->has('contexts') && $request->request->has('contexts')) {
$contexts = $this->form->get('contexts')->getData();
Expand Down
1 change: 1 addition & 0 deletions Form/Type/SystemCalendarType.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function configureOptions(OptionsResolver $resolver)
* PRE_SET_DATA event handler
*
* @param FormEvent $event
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function preSetData(FormEvent $event)
{
Expand Down
4 changes: 4 additions & 0 deletions Model/Recurrence/MonthNthStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Oro\Bundle\CalendarBundle\Entity;
use Oro\Bundle\CalendarBundle\Model\Recurrence;

/**
* Calendar strategy for events reocurring every Nth month.
*/
class MonthNthStrategy extends AbstractStrategy
{
/**
Expand All @@ -17,6 +20,7 @@ public function getName()

/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getOccurrences(Entity\Recurrence $recurrence, \DateTime $start, \DateTime $end)
{
Expand Down
6 changes: 2 additions & 4 deletions Model/Recurrence/WeeklyStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
use Oro\Bundle\CalendarBundle\Model\Recurrence;

/**
* Class WeeklyStrategy
* @package Oro\Bundle\CalendarBundle\Model\Recurrence
*
* The weekly strategy for the first week takes into account only that days that are later than start
* of recurrence and then it selects next days according to its interval.
* For example, the rule 'Weekly every 2 weeks on Monday, Friday every 2 weeks'
Expand Down Expand Up @@ -96,7 +93,7 @@ public function getOccurrences(Entity\Recurrence $recurrence, \DateTime $start,
) {
$result[] = $next;
}

$fromStartInterval = $next >= $recurrence->getStartTime() ? $fromStartInterval +1 : $fromStartInterval;
}
$fullWeeks += $interval;
Expand Down Expand Up @@ -186,6 +183,7 @@ protected function sortWeekDays(&$weekDays)
* {@inheritdoc}
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getLastOccurrence(Entity\Recurrence $recurrence)
{
Expand Down
4 changes: 4 additions & 0 deletions Provider/CalendarPropertyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use Oro\Bundle\EntityExtendBundle\Tools\ExtendHelper;
use Oro\Component\DoctrineUtils\ORM\QueryBuilderUtil;

/**
* Provides utility methods for retrieval of calendar properties.
*/
class CalendarPropertyProvider
{
const CALENDAR_PROPERTY_CLASS = 'Oro\Bundle\CalendarBundle\Entity\CalendarProperty';
Expand Down Expand Up @@ -56,6 +59,7 @@ public function __construct(
* @param int $calendarId
*
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getItems($calendarId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @dbIsolationPerTest
*
* @SuppressWarnings(PHPMD.ExcessiveClassLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class RecurringEventUpdateExceptionTest extends AbstractTestCase
{
Expand Down
2 changes: 2 additions & 0 deletions Tests/Unit/Manager/CalendarEvent/NotificationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/**
* @SuppressWarnings(PHPMD.ExcessiveClassLength)
* @SuppressWarnings(PHPMD.TooManyMethods)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class NotificationManagerTest extends \PHPUnit\Framework\TestCase
{
Expand Down
3 changes: 3 additions & 0 deletions Tests/Unit/Manager/CalendarEventManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use Oro\Bundle\OrganizationBundle\Entity\Organization;
use Oro\Bundle\SecurityBundle\Authentication\TokenAccessorInterface;

/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
class CalendarEventManagerTest extends \PHPUnit\Framework\TestCase
{
/** @var \PHPUnit\Framework\MockObject\MockObject */
Expand Down
1 change: 1 addition & 0 deletions Validator/RecurringCalendarEventExceptionValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected function validateRecurrence(
*
* @param CalendarEvent $value
* @param RecurringCalendarEventExceptionConstraint $constraint
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function validateCalendarUid(
CalendarEvent $value,
Expand Down

0 comments on commit 67d67db

Please sign in to comment.