Description

This module allow redirect any user in any node to anywhere.

The redirects could be configured for individual nodes or by content type.

Project link

https://www.drupal.org/project/redirect_page_by_role

Git instructions

git clone --branch '1.0.x' https://git.drupalcode.org/project/redirect_page_by_role.git

PAReview

https://pareview.net/r/405

Comments

wesleyl created an issue. See original summary.

marijan gudelj’s picture

Running pareview.net

Git errors:

It appears you are working in the "1.0.x" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the 1.0.x branch (commit 9141ab6):

Your README.md does not follow best practices (headings need to be uppercase). See https://www.drupal.org/node/2181737 .
The INTRODUCTION section is missing.
The REQUIREMENTS section is missing.
The INSTALLATION section is missing.
The CONFIGURATION section is missing.
The redirect_page_by_role.module does not implement hook_help(). See https://www.drupal.org/docs/develop/documenting-your-project/module-doc… .
Coder Sniffer has found some issues with your code (please check the Drupal coding standards). See attachment.
No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.

FILE: /var/www/pareviewd/pareview_temp/gxtmztfn/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 8 WARNINGS AFFECTING 8 LINES
----------------------------------------------------------------------
4 | WARNING | Line exceeds 80 characters; contains 81 characters
19 | WARNING | Line exceeds 80 characters; contains 102 characters
21 | WARNING | Line exceeds 80 characters; contains 151 characters
23 | WARNING | Line exceeds 80 characters; contains 94 characters
25 | WARNING | Line exceeds 80 characters; contains 129 characters
26 | WARNING | Line exceeds 80 characters; contains 113 characters
36 | WARNING | Line exceeds 80 characters; contains 123 characters
38 | WARNING | Line exceeds 80 characters; contains 113 characters
----------------------------------------------------------------------

FILE: .../www/pareviewd/pareview_temp/gxtmztfn/redirect_page_by_role.info.yml
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
--------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by
| | drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
--------------------------------------------------------------------------

FILE: ...r/www/pareviewd/pareview_temp/gxtmztfn/redirect_page_by_role.install
--------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
3 | ERROR | [x] Missing function doc comment
46 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: 'nid'
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: ...ar/www/pareviewd/pareview_temp/gxtmztfn/redirect_page_by_role.module
--------------------------------------------------------------------------
FOUND 10 ERRORS AND 4 WARNINGS AFFECTING 11 LINES
--------------------------------------------------------------------------
9 | WARNING | [x] Unused use statement
56 | WARNING | [ ] Format should be "* Implements hook_foo().", "*
| | Implements hook_foo_BAR_ID_bar() for xyz_bar().",,
| | "* Implements hook_foo_BAR_ID_bar() for
| | xyz-bar.html.twig.", "* Implements
| | hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "*
| | Implements hook_foo_BAR_ID_bar() for block
| | templates."
58 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
64 | ERROR | [x] Data types in @var tags need to be fully namespaced
97 | ERROR | [x] Comma not allowed after last value in single-line
| | array declaration
97 | ERROR | [x] Expected one space after the comma, 0 found
109 | ERROR | [x] Concat operator must be surrounded by a single space
113 | ERROR | [x] Concat operator must be surrounded by a single space
116 | WARNING | [ ] Translatable strings must not begin or end with
| | white spaces, use placeholders with t() for
| | variables
116 | ERROR | [ ] Concatenating translatable strings is not allowed,
| | use placeholders instead and only one string literal
124 | ERROR | [x] Concat operator must be surrounded by a single space
130 | ERROR | [x] Concat operator must be surrounded by a single space
195 | ERROR | [x] Spaces must be used to indent lines; tabs are not
| | allowed
195 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 3
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

First of all run your code through a formatter.

In the
add the comment to the first function

/**
 * Implements hook_schema().
 */

In the .module file remove

use Drupal\redirect_page_by_role\EnableService;

As it is not used.

Line 64
/** @var EnableService $enabler */
is not needed then as you will not be useing the Enabler service.

Line 97 instead of
'#header' => [t('Role'), t('Weight'),],
Switch it to
'#header' => [t('Role'), t('Weight')],
as there is no following array value.

The Concat operator must be surrounded by a single space is something that a proper formatter will fix.

#incorrect
'group-'.$id]

#correct
'group-' . $id]

On line 116 you have
'#title' => t('Redirect ' . $role->label() . ' to:'),
You need to use an placeholder so it would look something like this

#title' => t('Redirect @role to:',
['@role' =>$role->label() ]),
marijan gudelj’s picture

Status: Needs review » Needs work
marijan gudelj’s picture

Issue summary: View changes
wesleyl’s picture

Status: Needs work » Needs review

Fixed points addressed in #2 (https://git.drupalcode.org/project/redirect_page_by_role/-/commit/19398a...)

In .module file was removed the unused statement, but it was updated the comment on line 64, because the Enabler service is been used on:

  /** @var \Drupal\redirect_page_by_role\EnableService $enabler */
  $enabler = \Drupal::service('redirect_page_by_role.enabler');
  $is_enabled = $enabler->isEnabled($node);

What means this git error?

marijan gudelj’s picture

You corrected everything. I see nothing else
Automated review Passed

Manual review Passed
Breakdown:
Individual user account: yes
No duplication: yes
Master branch: Semantic (1.0.x)
Licensing : follows (nothing specified: falls under default Drupal GPL)
3rd party assets/code: no third party code
README.txt/README.md : follows
Code long/complex enough for review: Follows
Secure code: Yes
Coding style & Drupal API usage: Clear

marijan gudelj’s picture

Status: Needs review » Reviewed & tested by the community

Everything fixed and passed automated and manual review

avpaderno’s picture

  /**
   * Send redirect.
   *
   * @param array $redirect_rule
   *   Array with redirection info.
   */
  private function sendRedirect(array $redirect_rule) {
    $redirect = new RedirectResponse($redirect_rule['redirect_to'], $redirect_rule['status_code']);
    $redirect->send();
  }

A class that extends ControllerBase can use ControllerBase::redirect() instead on implementing its own method.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

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