0

I have been searching since yesterday for the resolution of two code sniffer errors :

62 | ERROR | [x] Expected 1 space after closing parenthesis; found
   |       |     " options.keys = $.extend(\n

Here is my code :

  if (newOptions.keys) options.keys = $.extend(
     {
     shift: 1,
     ctrl: 'resize' },
     newOptions.keys
  );

I would like to have the eye of an outside person to solve this, thanks for your attention :)

  • You're confusing it by not using curly braces for your if, I think? Especially with the curly braces for the object being on the same line. – Liam MacDonald May 10 '17 at 15:20
  • "phpcs --standard=PSR2" Tells me I have to jump the lines as above ( See my update) I have only one error, but I still do not see... – user7992606 May 10 '17 at 15:56

1 Answers1

1

I'd have to see the rest of the file to be able to generate and fix that Expected 1 space after closing parenthesis error, but if you want to format that IF statement in a way that PSR2 is happy with, you'd do this:

if (newOptions.keys) {
    options.keys = $.extend(
        {
            shift: 1,
            ctrl: 'resize'
        },
        newOptions.keys
    );
}

If you are using a standard that allows inline control structures, you can ignore the PSR2 error for that and use this code instead:

if (newOptions.keys) options.keys = $.extend(
    {
        shift: 1,
        ctrl: 'resize'
    },
    newOptions.keys
);
Greg Sherwood
  • 6,992
  • 2
  • 29
  • 24