From 30449cf1a6c64c317a705a083767993939fbd332 Mon Sep 17 00:00:00 2001 From: Jonathan Sacksick <21182-jsacksick@users.noreply.drupalcode.org> Date: Mon, 1 Jul 2024 09:13:55 +0000 Subject: [PATCH] Issue #3458232 by jsacksick: Fix CSPELL, stylelint and PHPStan issues. --- .gitlab-ci.yml | 3 +++ css/state.css | 18 +++++++++--------- phpstan-baseline.neon | 6 ++++++ src/Entity/Queue.php | 6 ++++-- src/Exception/DuplicateJobException.php | 8 ++++---- src/Form/QueueForm.php | 3 ++- .../AdvancedQueue/JobType/JobTypeInterface.php | 4 ++-- .../Plugin/AdvancedQueue/Backend/BaseOnly.php | 4 +++- 8 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e5384a8..414cbd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,3 +27,6 @@ include: # SKIP_ESLINT: '1' # OPT_IN_TEST_NEXT_MAJOR: '1' # _CURL_TEMPLATES_REF: 'main' +variables: + _CSPELL_IGNORE_PATHS: 'images/*, config/install/views.view.advancedqueue_jobs.yml' + _CSPELL_WORDS: 'queuename' \ No newline at end of file diff --git a/css/state.css b/css/state.css index 562bfa0..e985383 100644 --- a/css/state.css +++ b/css/state.css @@ -3,27 +3,27 @@ .advancedqueue-status-success, .advancedqueue-status-failure { display: inline-block; + width: 6em; height: 12px; - line-height: 12px; padding-left: 16px; - width: 6em; - background-position: 0 50%; background-repeat: no-repeat; + background-position: 0 50%; + line-height: 12px; } .advancedqueue-status-queued { - background-image: url('../images/queued.gif'); + background-image: url("../images/queued.gif"); } .advancedqueue-status-processing { - background-image: url('../images/processing.gif'); + background-image: url("../images/processing.gif"); } .advancedqueue-status-success { - background-image: url('../images/processed.png'); - color: #336633; + color: #363; + background-image: url("../images/processed.png"); font-weight: bold; } .advancedqueue-status-failure { - background-image: url('../images/failed.png'); - color: #ff0000; + color: #f00; + background-image: url("../images/failed.png"); font-weight: bold; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..7a5daee --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^\\\\Drupal calls should be avoided in classes, use dependency injection instead$#" + count: 1 + path: src/Processor.php diff --git a/src/Entity/Queue.php b/src/Entity/Queue.php index 0dec214..a1ad9a9 100644 --- a/src/Entity/Queue.php +++ b/src/Entity/Queue.php @@ -154,7 +154,7 @@ class Queue extends ConfigEntityBase implements QueueInterface { } /** - * Prepare a job for enqueuing. + * Prepare a job for enqueueing. * * @param \Drupal\advancedqueue\Job $job * The job to prepare. @@ -163,7 +163,7 @@ class Queue extends ConfigEntityBase implements QueueInterface { * A job to enqueue. This may or may not be the $job object supplied. * * @throws \Drupal\advancedqueue\Exception\InvalidBackendException - * Throws an exception if the queue's backend cannnot handle the given job. + * Throws an exception if the queue's backend cannot handle the given job. */ protected function prepareJob(Job $job): Job { $job->setQueueId($this->id()); @@ -293,9 +293,11 @@ class Queue extends ConfigEntityBase implements QueueInterface { // Invoke the setters to clear related properties. if ($property_name == 'backend') { $this->setBackendId($value); + return $this; } elseif ($property_name == 'backend_configuration') { $this->setBackendConfiguration($value); + return $this; } else { return parent::set($property_name, $value); diff --git a/src/Exception/DuplicateJobException.php b/src/Exception/DuplicateJobException.php index 7524ed0..cc447d1 100644 --- a/src/Exception/DuplicateJobException.php +++ b/src/Exception/DuplicateJobException.php @@ -7,13 +7,13 @@ use Drupal\advancedqueue\Job; /** * Exception thrown when a job is detected as a duplicate. * - * This is thrown when a new job being considered for queuing is recognised as + * This is thrown when a new job being considered for queueing is recognized as * a duplicate of one or more jobs that are already queued. */ class DuplicateJobException extends \Exception { /** - * The job submitted for enqueuing. + * The job submitted for enqueueing. * * @var \Drupal\advancedqueue\Job */ @@ -32,7 +32,7 @@ class DuplicateJobException extends \Exception { * @param string $message * A message describing the duplicate situation. * @param \Drupal\advancedqueue\Job $job - * The job that was submitted for enqueuing which had existing duplicates. + * The job that was submitted for enqueueing which had existing duplicates. * @param array[\Drupal\advancedqueue\Job|int|string] $duplicates * An array of duplicate jobs or duplicate job ids. Keyed by job id. */ @@ -43,7 +43,7 @@ class DuplicateJobException extends \Exception { } /** - * Get the job submitted for enqueuing. + * Get the job submitted for enqueueing. * * @return \Drupal\advancedqueue\Job * The job. diff --git a/src/Form/QueueForm.php b/src/Form/QueueForm.php index 04a3dc8..719af89 100644 --- a/src/Form/QueueForm.php +++ b/src/Form/QueueForm.php @@ -251,9 +251,10 @@ class QueueForm extends EntityForm { * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { - $this->entity->save(); + $save = $this->entity->save(); $this->messenger()->addStatus($this->t('Saved the %label queue.', ['%label' => $this->entity->label()])); $form_state->setRedirect('entity.advancedqueue_queue.collection'); + return $save; } } diff --git a/src/Plugin/AdvancedQueue/JobType/JobTypeInterface.php b/src/Plugin/AdvancedQueue/JobType/JobTypeInterface.php index 3bd21fd..7acf785 100644 --- a/src/Plugin/AdvancedQueue/JobType/JobTypeInterface.php +++ b/src/Plugin/AdvancedQueue/JobType/JobTypeInterface.php @@ -67,7 +67,7 @@ interface JobTypeInterface extends PluginInspectionInterface { public function process(Job $job); /** - * Handles existing jobs detected as duplicates when enqueing a new job. + * Handles existing jobs detected as duplicates when enqueuing a new job. * * A function can be used to execute a range of different strategies with * regard to duplicate jobs: @@ -81,7 +81,7 @@ interface JobTypeInterface extends PluginInspectionInterface { * - to discard the new job and leave the duplicate intact, return NULL. * * @param \Drupal\advancedqueue\Job $job - * The new job submitted for enqueuing. + * The new job submitted for enqueueing. * @param array[\Drupal\advancedqueue\Job|string|int] $duplicates * An array of jobs or job ids that are duplicates of the new job. * Keyed by job id. diff --git a/tests/modules/advancedqueue_test/src/Plugin/AdvancedQueue/Backend/BaseOnly.php b/tests/modules/advancedqueue_test/src/Plugin/AdvancedQueue/Backend/BaseOnly.php index 540c180..ced9dcc 100644 --- a/tests/modules/advancedqueue_test/src/Plugin/AdvancedQueue/Backend/BaseOnly.php +++ b/tests/modules/advancedqueue_test/src/Plugin/AdvancedQueue/Backend/BaseOnly.php @@ -42,7 +42,9 @@ class BaseOnly extends BackendBase { /** * {@inheritdoc} */ - public function countJobs() {} + public function countJobs() { + return []; + } /** * {@inheritdoc} -- GitLab