- Issue created by @benjifisher
- last update
12 months ago 4 pass - Status changed to Needs review
12 months ago 1:00am 19 January 2024 - πΊπΈUnited States benjifisher Boston area
You can confirm that the CI is running tests. See the results at https://git.drupalcode.org/project/rest_views/-/merge_requests/11/pipelines
When MR !11 is merged, you (the maintainer) can go to https://www.drupal.org/node/2858988/qa β and disable testing on the legacy DrupalCI, at least for the 3.0.x branch. I copied the link in the issue summary, GitLab CI β , from that page.
- last update
12 months ago 4 pass 12:27 11:43 Running- Issue was unassigned.
- πΊπΈUnited States benjifisher Boston area
I do not like failing tests, so I added some commits to keep
phpcs
andphpstan
happy. I will add details to the issue summary. - First commit to issue fork.
- last update
12 months ago 4 pass - Status changed to Needs work
12 months ago 4:20pm 19 January 2024 - πΊπΈUnited States nicxvan
Thank you for this!
I fixed a t() warning I still need to test.
I also added four // phpcs:ignore comments because they are overriding core views methods so I'm not sure why those are throwing a warning still.
The main issue is now that phpcs is passing stylelint is failing because it can't find a css file.
Can we disable stylelint since this project has no css libraries?
- πΊπΈUnited States benjifisher Boston area
I think this explains why
phpcs
does not flag those violations in the coreviews
module: fromcore/phpcs.xml.dist
:<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.--> <!-- Drupal sniffs --> <rule ref="Drupal.Arrays.Array"> <!-- Sniff for these errors: ArrayClosingIndentation, ArrayIndentation, CommaLastItem --> <exclude name="Drupal.Arrays.Array.LongLineDeclaration"/> </rule> ...
- πΊπΈUnited States benjifisher Boston area
It looks as though there are only three places where
EXPORT_OPTIONS
is used:class ListExportFormatter extends FormatterBase { const VALUE_LABEL = 'value_label'; const KEY_VALUE = 'key_value'; const EXPORT_OPTIONS = [ self::VALUE_LABEL => 'Export label and value separately', self::KEY_VALUE => 'Export as key/value', ]; // ... $elements['export_format'] = [ '#type' => 'radios', '#title' => $this->t('Export format'), '#default_value' => $this->getSetting('export_format'), '#options' => array_map([$this, 't'], self::EXPORT_OPTIONS), ]; // ... $summary[] = $this->t('@options', ['@options' => self::EXPORT_OPTIONS[$export_format]]);
Really it should be done like this:
class ListExportFormatter extends FormatterBase { const VALUE_LABEL = 'value_label'; const KEY_VALUE = 'key_value'; const EXPORT_OPTIONS = [ self::VALUE_LABEL => $this->t('Export label and value separately'), self::KEY_VALUE => $this->t('Export as key/value'), ]; // ... $elements['export_format'] = [ '#type' => 'radios', '#title' => $this->t('Export format'), '#default_value' => $this->getSetting('export_format'), '#options' => self::EXPORT_OPTIONS, ]; // ... $summary[] = self::EXPORT_OPTIONS[$export_format];
The only problem is that I do not think you can use
$this->t()
in aconst
definition. You should be able to do it in a constructor, after calling the parent constructor. That is, use a class property (maybe astatic
one) instead of aconst
. - πΊπΈUnited States benjifisher Boston area
The main issue is now that phpcs is passing stylelint is failing because it can't find a css file.
Where do you see that? Or did you already do something to fix it?
- Status changed to Needs review
12 months ago 8:35pm 20 January 2024 - πΊπΈUnited States nicxvan
I'm using this: https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-dr... β
When I run it I get this message:
PASS composer
PASS composer-lint
PASS phpcs
PASS phpstan
PASS eslint
PASS phpunit
FAIL stylelint
> at standalone (/gcl-builds/web/core/node_modules/stylelint/lib/standalone.js:261:43)
> Error: No files matching the pattern "../modules/custom/**/*.css" were found.
> at standalone (/gcl-builds/web/core/node_modules/stylelint/lib/standalone.js:261:43)
pipeline finished in 1.35 minAlthough the actual tests are not failing so I can work on resolving that locally.
I'll take a look at your other comments.
- last update
12 months ago 4 pass - last update
12 months ago 4 pass - πΊπΈUnited States benjifisher Boston area
@nicxvan:
Yes, using a function like that looks good to me. You are correctly using
$this->t()
on literal strings, and I expect the overhead of a function call is just microseconds. If I am wrong about that, then you can use the familiar patternfunction getExportOptions() { if (empty($this->exportOptions)) { $this->exportOptions = ... } return $this->exportOptions; }
But I would not bother with that unless it is actually a problem.
One little complaint: the Coding standards β say,
Variables should be named using lowercase, and words should be separated either with uppercase characters (example:
$lowerCamelCase
) or with an underscore (example:<code>$snake_case
). Be consistent; do not mix camelCase and snake_case variable naming inside a file.The file already uses
snake_case
for some variables ($export_format
and$form_state
) and now it useslowerCamelCase
for others ($exportFormat
and$exportOptions
).I cannot mark this issue RTBC, since I made the changes before the last two commits. But those two commits LGTM.
- last update
12 months ago 4 pass - Status changed to Fixed
12 months ago 7:45pm 23 January 2024 - πΊπΈUnited States nicxvan
Good point, I usually leave items like form_state from core snake case, I've updated everything to camelCase.
I merged this in, thanks for your contribution!
- Status changed to Needs review
12 months ago 11:24pm 23 January 2024 - πΊπΈUnited States benjifisher Boston area
That's the sort of change you make when you decide that the module is really your own. ;)
- Status changed to Fixed
12 months ago 1:37pm 24 January 2024 - πΊπΈUnited States benjifisher Boston area
Oops, I did not mean to move this issue back to NR.
Automatically closed - issue fixed for 2 weeks with no activity.