Problem/Motivation

PHPCS found the following errors:

FILE: /var/opt/docker/apps/sasi/html/modules/contrib/profile_switcher/README.md
-------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
-------------------------------------------------------------------------------
  3 | WARNING | Line exceeds 80 characters; contains 112 characters
  8 | WARNING | Line exceeds 80 characters; contains 91 characters
 16 | WARNING | Line exceeds 80 characters; contains 108 characters
 17 | WARNING | Line exceeds 80 characters; contains 260 characters
 19 | WARNING | Line exceeds 80 characters; contains 281 characters
-------------------------------------------------------------------------------


FILE: /var/opt/docker/apps/sasi/html/modules/contrib/profile_switcher/src/Commands/ProfileSwitcherCommands.php
--------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------------------
 14 | ERROR   | [x] Doc comment short description must end with a full stop
 23 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 33 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 35 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------------


FILE: /var/opt/docker/apps/sasi/html/modules/contrib/profile_switcher/src/ProfileSwitcher.php
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
 37 | ERROR | Parameter $state is not described in comment
---------------------------------------------------------------------------------------------


FILE: /var/opt/docker/apps/sasi/html/modules/contrib/profile_switcher/profile_switcher.drush.inc
------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------
  1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
  3 | ERROR | [x] Doc comment short description must be on the first line
 10 | ERROR | [x] Short array syntax must be used to define arrays
 25 | ERROR | [ ] Missing parameter comment
 27 | ERROR | [x] Additional blank lines found at end of doc comment
------------------------------------------------------------------------------------------------
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

smulvih2 created an issue. See original summary.

smulvih2’s picture

Status: Active » Needs review

Patch to fix PHPCS errors.

smulvih2’s picture

Matheus Macario’s picture

Assigned: Unassigned » Matheus Macario
Matheus Macario’s picture

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

So, after have done the code review on the #3 patch , i noticed that there are still some errors and warnings popping out on terminal. The profile-switcher-phpcs-errors-3250768-3.patch(#3) fix plenty of errors but there are some dependency injection issues on the ProfileSwitcherCommands.php file . I attached a txt file showing these errors after the patch been applied. With that been said i'm changing the status to ''needs work''.

Matheus Macario’s picture

Assigned: Matheus Macario » Unassigned
smulvih2’s picture

Status: Needs work » Needs review
StatusFileSize
new6.69 KB

New patch also fixes PHPCS warnings.

I'm running PHPCS with the following parameters:
--standard="Drupal,DrupalPractice" --extensions="php,module,inc,install,test,profile,theme,md,info"

smulvih2’s picture

Status: Needs review » Needs work

Issue with too few arguments. Need more time to resolve dependency injection issue.

tmaiochi’s picture

Assigned: Unassigned » tmaiochi

I'll work on this.

tmaiochi’s picture

Assigned: tmaiochi » Unassigned

I tried to do the dependecy injection, but I couldn't find the services necessary to do this, so I'm leaving this issue for someone else can try

beatrizrodrigues’s picture

Assigned: Unassigned » beatrizrodrigues

I will work on the dependency injection here

beatrizrodrigues’s picture

Assigned: beatrizrodrigues » Unassigned

I couldn't proceed with that issue right know, sorry.

Willy Christian’s picture

Working on it.

Willy Christian’s picture

Status: Needs work » Needs review
StatusFileSize
new7.87 KB

The patch #7 already fixed DI. Was missing only line size in a few files.

joachim’s picture

Status: Needs review » Needs work

The DI needs work -- currently it crashes.

  1. +++ b/README.md
    @@ -1,22 +1,35 @@
    +* _Always_ test before using on a live site and _Always_ have a backup.
    

    Typo in the 2nd 'Always'.

  2. +++ b/README.md
    @@ -1,22 +1,35 @@
    +* Because some modules register absolute paths to files in Drupal's registry ¶
    +  table, you may run into issues when switching profiles even if the version
    +  of the module is the same.
    +  (See [Tips for fixing registry related issues](https://drupal.org/node/1974964)).
    +* If the Profile Switcher module was included in a ¶
    +  `/profile/[profile_name]/modules` directory and you switch to a profile ¶
    +  that doesn't include it, you will get a page-not-found error after the switch, ¶
    +  and not be able to switch back until adding this module to `sites/all/modules`
    +  .
    

    Stray whitespace.

  3. +++ b/profile_switcher.info.yml
    @@ -4,4 +4,4 @@ type: module
     core: 8.x
    

    AFAIK this can be removed too.

  4. +++ b/profile_switcher.info.yml
    @@ -4,4 +4,4 @@ type: module
    -version: ' 8.x-0.1'
    +# Will be added by Drupal.org package version: ' 8.x-0.1'
    

    This can just be removed.

  5. +++ b/src/Commands/ProfileSwitcherCommands.php
    @@ -4,14 +4,44 @@ namespace Drupal\profile_switcher\Commands;
    +  public function __construct(ConfigFactoryInterface $config_factory, ProfileSwitcher $profile_switcher) {
    +    $this->configFactory = $config_factory;
    +    $this->profileSwitcher = $profile_switcher;
    +  }
    

    This needs the injected services to be declared as parameters in the yml file.

  6. +++ b/src/Commands/ProfileSwitcherCommands.php
    @@ -20,19 +50,27 @@ class ProfileSwitcherCommands extends DrushCommands {
    +      "The site's install profile will be switched from !profile_to_remove ¶
    

    A quoted string shouldn't be wrapped like that.

smulvih2’s picture

Issue summary: View changes
smulvih2’s picture

Status: Needs work » Needs review
StatusFileSize
new8.08 KB

Fixed issue with DI, ready for review.

Guilherme Rabelo’s picture

Assigned: Unassigned » Guilherme Rabelo

I'll review this patch.

Guilherme Rabelo’s picture

Assigned: Guilherme Rabelo » Unassigned
Status: Needs review » Reviewed & tested by the community

I apply the #17 patch and all coding standards messages in PHPCS have been fixed.
Moving to RTBC.

rajeshreeputra’s picture

RTBC +1

kreynen made their first commit to this issue’s fork.

  • kreynen committed 53a2bf5 on 8.x-1.x authored by smulvih2
    Issue #3250768 by smulvih2, Willy Christian, kreynen, Matheus Macario,...
kreynen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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