Problem/Motivation

FILE: ...wdalmnb/src/Plugin/Field/FieldFormatter/CloudflareVideoFormatter.php
--------------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------
76 | WARNING | [ ] Avoid backslash escaping in translatable strings
| | when possible, use "" quotes instead
124 | WARNING | [ ] Translatable strings must not begin or end with
| | white spaces, use placeholders with t() for
| | variables
127 | ERROR | [x] There should be no white space before a closing ")"
197 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
205 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pjbaert created an issue. See original summary.

mohit.bansal623 made their first commit to this issue’s fork.

mohit.bansal623’s picture

Status: Active » Needs review

Please review the merge request.

tim-diels’s picture

Status: Needs review » Needs work

Please see reviews. Needs work.

mohit.bansal623’s picture

StatusFileSize
new2.59 KB

Uploading the patch.

mohit.bansal623’s picture

Status: Needs work » Needs review
tim-diels’s picture

Status: Needs review » Needs work

Please visually review what you have done. I think you removed spaces that were needed for better readability.

mohit.bansal623’s picture

Status: Needs work » Needs review

I have only removed that space which is needed and detected by codesniffer.

tim-diels’s picture

Status: Needs review » Needs work

It's good that you try to remove the whitespace, but the whitespace is added for visibility purposes. If you would go to the UI where these settings are, you would note the difference after your patch which is not desirable.
It is not just blindly changing text.

  1. +++ b/src/Plugin/Field/FieldFormatter/CloudflareVideoFormatter.php
    @@ -118,13 +118,16 @@ class CloudflareVideoFormatter extends FormatterBase {
    +        '@muted' => $this->getSetting('muted') ? $this->t('muted,') : '',
    

    This should be '@muted' => $this->getSetting('muted') ? $this->('muted') . ', ' : '',

  2. +++ b/src/Plugin/Field/FieldFormatter/CloudflareVideoFormatter.php
    @@ -118,13 +118,16 @@ class CloudflareVideoFormatter extends FormatterBase {
    +        '@controls' => $this->getSetting('controls') ? $this->t(', controls visible') : '',
    

    This should be '@controls' => $this->getSetting('controls') ? ', ' . $this->('controls visible') : '',

mohit.bansal623’s picture

Status: Needs work » Needs review
StatusFileSize
new2.67 KB

@tim-diels - Got your point. Thanks for your valuable feedback.

But if I tried your solution then it prompted with another error -
Do not concatenate strings to translatable strings, they should be part of the t() argument and you should use placeholders

So what I did now, I have given one space after @muted in line no 126. Hope that works well.

tim-diels’s picture

Status: Needs review » Needs work

And again I ask to test this visually and not only change the code. This gives not the correct output when testing with not muted and muted, gives us extra space.

@mohit.bansal623 You're correct on the CS for concatenation.

We'll have to look for another way to display the summary. Suggestions are welcome.
My suggestion is to not display the values in a single line, but break this up over multiple lines like Drupal does for most of its fields.

tim-diels’s picture

Status: Needs work » Needs review
StatusFileSize
new11.74 KB
new10.01 KB
new9 KB
new2.95 KB

Before changes:

Example:

After changes:

The text can maybe chosen better.

pjbaert’s picture

StatusFileSize
new2.96 KB
new50.7 KB

Thanks @tim-diels for your update. I like the way you're going with this solution.
I tested this patch & started fiddling around with the copy.
Find attached my patch.
What are your thoughts?

patch

mohit.bansal623’s picture

This looks good @pjabert. We can display like this.

tim-diels’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the follow up. It's much better indeed than what we now have. For me this is good to go.

  • pjbaert committed ca8ce57 on 8.x-2.x
    Issue #3236364 by mohit.bansal623, tim-diels, pjbaert: Fix codesniffer...
pjbaert’s picture

Status: Reviewed & tested by the community » Fixed

What a team effort! Pushed to 2.x branch. Thanks for the help!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.