I really appreciate this module, but I had a hard time reading the code.

This patch re-writes a lot of the code according to Drupal's coding standards.

And I've provided the whole lot as a ZIP file, in case it's easier to read that way.

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tarekdj’s picture

Issue summary: View changes
Issue tags: +Novice, +TUNIS_2014_FEBRUARY

Issue marked for Tunisian local sprint next week.

willieseabrook’s picture

FileSize
12.22 KB

I have rerolled the patch against 7.x-2.x latest. See attached

Chi’s picture

Priority: Minor » Normal
Status: Needs review » Needs work
Issue tags: +Needs a reroll

The patch is outdated.

darol100’s picture

Assigned: Unassigned » darol100
darol100’s picture

Status: Needs work » Needs review
FileSize
4.98 KB

I have created a new patch that will fix all Drupal standards coding errors.

I only have one warning that I did not figure out how to fix it.

--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 16 | WARNING | Only string literals should be passed to t() where possible
--------------------------------------------------------------------------------
darol100’s picture

Assigned: darol100 » Unassigned
Chi’s picture

Status: Needs review » Needs work

Only string literals should be passed to t() where possible

I think it's a bad practice using t() function for variable translation. Here are some explanations: http://hojtsy.hu/blog/2011-may-19/drupals-multilingual-problem-why-t-wro...
Common way to translate variables is using i18n module. https://www.drupal.org/node/1113374

- drupal_add_js(array('scroll_to_top' => array('label' => t(variable_get('scroll_to_top_label', 'Back to top')))), 'setting')
+ drupal_add_js(array('scroll_to_top' => array('label' => variable_get('scroll_to_top_label', 'Back to top'))), 'setting')
darol100’s picture

@Chi
Thank you for the amazing resources.

I have created another patch where will fix ALL Drupal Coding Standards errors.

darol100’s picture

Status: Needs work » Needs review
jwilson3’s picture

Issue tags: -Needs a reroll +Needs reroll
darol100’s picture

What is Needs to reroll means ?

tarekdj’s picture

Needs reroll means that the code changed and the patch does not apply anymore.
https://www.drupal.org/contributor-tasks/reroll

darol100’s picture

I can submitted an updated version of the patch. But would be possible to give it a priority so this does not have to be re-rolling over and over again ?

dhanushka madushan’s picture

the patch applied cleanly

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

anabpv’s picture

Assigned: Unassigned » anabpv

I will work on this issue

anabpv’s picture

Assigned: anabpv » Unassigned
Status: Needs review » Needs work
FileSize
11.38 KB

I ran phpcs and phpcbf and fixed most issues.
The ones that still need to be fixed are these:

FILE: /modules/contrib/scroll_to_top/scroll_to_top.module
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
 14 | WARNING | Do not use drupal_add_css() in hook_init(), use #attached for CSS and JS in your page/form callback or in
    |         | hook_page_build() instead
 18 | WARNING | Do not use drupal_add_js() in hook_init(), use #attached for CSS and JS in your page/form callback or in
    |         | hook_page_build() instead
 19 | WARNING | Do not use drupal_add_js() in hook_init(), use #attached for CSS and JS in your page/form callback or in
    |         | hook_page_build() instead
 42 | WARNING | Do not use drupal_add_css() in hook_init(), use #attached for CSS and JS in your page/form callback or in
    |         | hook_page_build() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /modules/contrib/scroll_to_top/scroll_to_top.info
-----------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------
 5 | ERROR | It's only necessary to declare files[] if they declare a class or interface.
 6 | ERROR | It's only necessary to declare files[] if they declare a class or interface.
-----------------------------------------------------------------------------------------------------------------

Time: 65ms; Memory: 10MB

Since these errors still need to be corrected, I'm changing the status to Needs Work.

Johnny Santos’s picture

Assigned: Unassigned » Johnny Santos

Ok, im going for this

Johnny Santos’s picture

Just an update, I applied the last patch and run phpcs as well as phpcbf and what I got was this, as listed below:

FILE: ...t-drupal_useful_scripts-20f10c7ee60f/d7webform/sites/all/modules/scroll_to_top/scroll_to_top.admin.inc
------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
------------------------------------------------------------------------------------------------------------
3 | ERROR | Missing short description in doc comment
6 | WARNING | PHP version not specified
6 | ERROR | Missing @category tag in file comment
6 | ERROR | Missing @package tag in file comment
6 | ERROR | Missing @author tag in file comment
6 | ERROR | Missing @license tag in file comment
6 | ERROR | Missing @link tag in file comment
10 | ERROR | Missing @return tag in function comment
11 | ERROR | Function name "scroll_to_top_settings" is prefixed with a package name but does not begin
| | with a capital letter
11 | ERROR | Function name "scroll_to_top_settings" is invalid; consider "Scroll_To_Top_settings"
| | instead
17 | WARNING | Line exceeds 85 characters; contains 89 characters
64 | WARNING | Line exceeds 85 characters; contains 171 characters

Johnny Santos’s picture

Please do not consider my last comment, I used the wrong standart, instead of Drupal's.

Johnny Santos’s picture

Assigned: Johnny Santos » Unassigned
Status: Needs work » Needs review

Ok, so after using phpcs with the right standart, I got the same log as the comment #17.
Worked on it, and now its pushed and fixed.
Changing to needs review status.

matheusmaciel’s picture

Assigned: Unassigned » matheusmaciel

I'll review it!

matheusmaciel’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
75.43 KB
376.96 KB
143.46 KB

I reviewed the issue with the phpcs and everything looks fine.
The "arrow.png" file shows that the module still works.
The "error_screen_2022-05-16 11-31-59.png" file shows the phpcs error messages.
And lastly, the "correct_screen2022-05-16 11-38-06.png" file shows the phpcs output (which is none) after the last commited work done.

matheusmaciel’s picture

Assigned: matheusmaciel » Unassigned