Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#32444 closed defect (bug) (fixed)

Scrutinizer in 4.3

Reported by: wonderboymusic's profile wonderboymusic Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.3
Component: General Keywords:
Focuses: Cc:

Description

Tracking ticket for improving static analysis

Attachments (7)

32444.diff (5.7 KB) - added by wonderboymusic 9 years ago.
32444.2.diff (6.0 KB) - added by wonderboymusic 9 years ago.
32444.3.diff (51.8 KB) - added by wonderboymusic 9 years ago.
32444.4.diff (31.1 KB) - added by wonderboymusic 9 years ago.
32444.5.diff (27.0 KB) - added by wonderboymusic 9 years ago.
32444.6.diff (8.1 KB) - added by wonderboymusic 9 years ago.
32444.7.diff (21.0 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (131)

#1 @wonderboymusic
9 years ago

  • Owner set to wonderboymusic
  • Status changed from new to assigned

#3 @wonderboymusic
9 years ago

In 32515:

In wpdb::load_col_info(), don't fetch the number of fields in the result row on each iteration of the for loop. It can be stored in a var and referenced.

See #32444.

#4 @wonderboymusic
9 years ago

In 32516:

In WP_Comments_List_Table::column_comment(), all of the nonced URLs can be defined in the same conditional block in which they are used. Not doing this causes ambiguity, and local vars are set that are not available to all execution paths.

See #32444.

#5 @wonderboymusic
9 years ago

In 32517:

In WP_Media_List_Table::get_views(), declare $num_posts explicitly before looping.

See #32444.

#6 @wonderboymusic
9 years ago

In 32525:

In admin-bar.php, most functions simply return when a conditional is not met. wp_admin_bar_render() shouldn't explicitly return false.

See #32444.

#7 @wonderboymusic
9 years ago

In 32526:

In author-template.php, clarify/add some return docs.

See #32444.

#8 @wonderboymusic
9 years ago

In 32527:

In bookmark.php, clarify some return docs.

See #32444.

#9 @wonderboymusic
9 years ago

In 32528:

In cache.php, clarify some return docs. Some WP_Object_Cache methods return void, so those wrapper functions don't need to return at all.

See #32444.

#10 @wonderboymusic
9 years ago

In 32529:

In canonical.php:

  • Clarify some docs
  • redirect_canonical() inconsistently returns null or false when bailing - can simply return.

See #32444.

#11 @wonderboymusic
9 years ago

In 32530:

In capabilities.php, clarify/add some return docs.

See #32444.

#12 @wonderboymusic
9 years ago

In 32531:

In category-template.php:

  • Clarify/add some return docs.
  • In walk_category_tree() and walk_category_dropdown_tree(), make behavior consistent and don't pass $walker by-reference - it is no longer necessary to do that with object instances.

See #32444.

#13 @wonderboymusic
9 years ago

In 32532:

In category.php:

  • Clarify some return docs.
  • In _make_cat_compat(), ensure that WP_Error is not decorated

See #32444.

#14 @wonderboymusic
9 years ago

In 32533:

In class-oembed.php, clarify/add some return docs.

See #32444.

#15 @wonderboymusic
9 years ago

In 32534:

In class-wp-admin-bar.php, clarify/add some doc blocks.

See #32444.

#16 follow-up: @wonderboymusic
9 years ago

In 32535:

In class-wp-customize-*, clarify/add some @param/@return blocks. Disambiguate some functions that are trying to return the void response of another function they call internally.

See #32444.

#17 in reply to: ↑ 16 @westonruter
9 years ago

Replying to wonderboymusic:

In 32535:

In class-wp-customize-*, clarify/add some @param/@return blocks. Disambiguate some functions that are trying to return the void response of another function they call internally.

See #32444.

Replacing return null with just return raises flags in PhpStorm: “Missing return argument”. Does scrutinizer complain when null is used, even when @return array|null is part of the phpDoc?

#18 @wonderboymusic
9 years ago

In 32536:

Add missing doc blocks to class-wp-editor.php.

See #32444.

#19 @wonderboymusic
9 years ago

In 32537:

Add missing doc blocks to admin-bar.php.

See #32444.

#20 @wonderboymusic
9 years ago

In 32538:

Add missing doc blocks to author-template.php.

See #32444.

#21 @wonderboymusic
9 years ago

In 32539:

Add/standardize missing doc blocks for cache.php.

See #32444.

#22 @wonderboymusic
9 years ago

In 32540:

Add missing doc blocks for canonical.php.

See #32444.

@wonderboymusic
9 years ago

#23 @wonderboymusic
9 years ago

In 32541:

Create a function, wp_roles(), to DRY the inline instantiation of the $wp_roles global.

Add missing doc blocks for capabilities.php.

See #32444.

#24 @wonderboymusic
9 years ago

In 32542:

Clean up @global doc blocks/imports for class-wp-customizer-*.php and friends.

See #32444.

#25 @wonderboymusic
9 years ago

In 32543:

Clean up @global doc blocks/imports for class-wp-editor.php.

See #32444.

#26 @wonderboymusic
9 years ago

In 32544:

Clean up doc blocks for class-wp-embed.php.

See #32444.

#27 follow-up: @wonderboymusic
9 years ago

In 32545:

When calling unset(), it is unnecessary to immediately precede it with a call to isset().

See #32444.

#28 @wonderboymusic
9 years ago

In 32546:

Add missing doc blocks to wp-image-editor*.php.

See #32444.

#29 @wonderboymusic
9 years ago

In 32547:

Add missing doc blocks to class-wp-theme.php.

See #32444.

#30 @DrewAPicture
9 years ago

In 32548:

Add a missing @since version to a function introduced in [32541].

See #32444.

#31 @wonderboymusic
9 years ago

In 32549:

Cleanup missing doc blocks for class-wp-walker.php.

See #32444.

#32 @wonderboymusic
9 years ago

In 32550:

Upgrade the doc blocks in class-wp-xmlrpc-server.php. Rehabilitate some unfortunate use of tabbing.

See #32444.

#33 @wonderboymusic
9 years ago

In 32551:

Add missing doc blockss in class-wp.php.

See #32444.

#34 @wonderboymusic
9 years ago

In 32566:

Add missing doc blocks to class.wp-(scripts|styles).php.

See #32444.

#35 @wonderboymusic
9 years ago

In 32567:

Add missing doc blocks to comment-template.php.

See #32444.

#36 @wonderboymusic
9 years ago

In 32568:

Use void instead of null where appropriate when pipe-delimiting @return types. If a @return only contains void, remove it.

See #32444.

#37 @wonderboymusic
9 years ago

In 32587:

Add missing doc blocks to comment.php.

See #32444.

#38 @wonderboymusic
9 years ago

In 32588:

Alter some @return doc blocks for cron.php.

See #32444.

#39 @wonderboymusic
9 years ago

In 32589:

Add missing doc blocks to default-widgets.php.
Move add_action() for widgets to default-filters.php with its brethren.

See #32444.

#40 @wonderboymusic
9 years ago

In 32590:

Add missing doc blocks to formatting.php.
Rehabilitate the spacing of various doc blocks.
Standardize some return values that are adjacent to similar functions.

See #32444.

#41 @wonderboymusic
9 years ago

In 32595:

Add missing doc blocks to wp-includes/functions.php.

See #32444.

#42 @wonderboymusic
9 years ago

In 32596:

Cleanup the use of $wp_scripts global in functions.wp-scripts.php.

See #32444.

#43 @wonderboymusic
9 years ago

In 32597:

Cleanup the use of $wp_styles global in functions.wp-styles.php.

See #32444.

#44 @wonderboymusic
9 years ago

In 32598:

Cleanup doc blocks in general-template.php.

See #32444.

#45 @wonderboymusic
9 years ago

In 32599:

Cleanup doc blocks in http.php.
In the few functions that used $objFetchSite instead of $http: use the $http naming, which is more civilized.

See #32444.

#46 @wonderboymusic
9 years ago

In 32600:

get_comments() can return int, so a few places need to check if the return value is traversable before passing what is assumed to be an array.

See #32444.

#47 @wonderboymusic
9 years ago

In 32603:

Add missing doc blocks to kses.php - also fix some unfortunate whitespace issues in related funcs.

See #32444.

#48 @wonderboymusic
9 years ago

In 32605:

Add missing doc blocks to l10n.php

See #32444.

#49 @wonderboymusic
9 years ago

In 32606:

Fix doc blocks to link-template.php

See #32444.

#50 @wonderboymusic
9 years ago

In 32607:

Add missing doc blocks to load.php

See #32444.

#51 @wonderboymusic
9 years ago

In 32608:

Add missing doc blocks to locale.php

See #32444.

#52 @wonderboymusic
9 years ago

In 32609:

Fix doc blocks for media*.php

See #32444.

#53 @wonderboymusic
9 years ago

In 32610:

Fix doc blocks for meta.php

See #32444.

#54 @wonderboymusic
9 years ago

In 32611:

Fix doc blocks for ms-*.php files.
A few functions can return a conditional instead of an if/else of true/false.

See #32444.

#55 @wonderboymusic
9 years ago

In 32612:

Fix doc blocks for nav-menu*.php files.

See #32444.

#56 @wonderboymusic
9 years ago

In 32613:

Fix doc blocks for option.php.

See #32444.

#57 @wonderboymusic
9 years ago

In 32614:

Add missing doc blocks for pluggable.php.
Correct some @return values.
is_user_logged_in() can simply return the ->exists() call instead of if/else'ing true/false.

See #32444.

#58 @wonderboymusic
9 years ago

In 32615:

Add missing doc blocks to plugin.php.
has_filter() can use strict comparison when checking $has internally.

See #32444.

#59 @wonderboymusic
9 years ago

In 32616:

Add missing doc blocks to post-formats.php.
Correct some types for @param and @return.

See #32444.

#60 @wonderboymusic
9 years ago

In 32617:

Add missing doc blocks to post-template.php.
Correct some types for @param and @return.
is_page_template() can return the conditional instead of if/else true/false.

See #32444.

#61 @wonderboymusic
9 years ago

In 32618:

Add missing doc blocks to post-thumbnail-template.php.

See #32444.

#62 @wonderboymusic
9 years ago

In 32619:

Add missing doc blocks to post.php.
Clarify some existing values for @param and @return.
Some functions do not need to set a variable before immediately returning it.

See #32444.

#63 @wonderboymusic
9 years ago

In 32620:

Add missing doc blocks to query.php.
Clarify @return values where necessary.
Some wrapper functions don't need to return if the function they wrap doesn't return.

See #32444.

#64 @wonderboymusic
9 years ago

In 32621:

Add missing doc blocks to revision.php.
Clarify @return values where necessary.
In wp_delete_post_revision(), wp_delete_post() doesn't return WP_Error, so that check can be removed.
wp_revisions_to_keep() always returns an int, so wp_revisions_enabled() can use strict comparison.

See #32444.

#65 @wonderboymusic
9 years ago

In 32622:

Add missing doc blocks to rewrite.php.
Clarify @return values where necessary.
add_permastruct() doesn't need to return.
->using_index_permalinks() and ->using_mod_rewrite_permalinks() can just return their conditions, instead of if/else true/false.
->mod_rewrite_rules() and ->iis7_url_rewrite_rules() don't need to set a variable that is immediately returned.

See #32444.

#66 @wonderboymusic
9 years ago

In 32623:

Add missing doc blocks to script-loader.php.
Use wp_styles() and wp_scripts() where appropriate.

See #32444.

#67 @wonderboymusic
9 years ago

In 32624:

Add missing doc blocks to shortcodes.php.

See #32444.

#68 @wonderboymusic
9 years ago

In 32627:

Add missing doc blocks to taxonomy.php.
Correct some @return values.
Some functions can return new WP_Error without setting it to a variable.
Some functions can return their apply_filters(...) call without first setting it to a variable.
is_object_in_taxonomy() can return its conditional instead of if/else true/false.

See #32444.

#69 @wonderboymusic
9 years ago

In 32628:

Add missing doc blocks to template.php.

See #32444.

#70 follow-up: @wonderboymusic
9 years ago

In 32629:

Add missing doc blocks to theme.php.
Correct some @return values.

See #32444.

#71 in reply to: ↑ 70 @nacin
9 years ago

Replying to wonderboymusic:

In 32629:

Add missing doc blocks to theme.php.
Correct some @return values.

See #32444.

This broke something, see [32632]. Something to watch for.

#72 @wonderboymusic
9 years ago

In 32635:

Add missing doc blocks to update.php:

  • wp_version_check(), wp_update_plugins(), and wp_update_themes() do not return meaningful responses, and their responses are never handled by core. As such, they shouldn't alternately return void or false. "Returning" in those functions is just "bailing"
  • In the same functions, version.php doesn't need to load if WP_INSTALLING is defined - the function will immediately bail, the values will never be read, and the globals won't be reset. I have unified the approach in all 3 functions.
  • When returning filtered $locale, there is no need to set the variable twice.
  • In _maybe_update_core(), isset() can take multiple values to bail before the call to time(), if necessary. This is a micro-optimization to prevent PHP from hitting the OS unnecessarily.

See #32444.

#73 @wonderboymusic
9 years ago

In 32637:

Add missing doc blocks to user.php.
username_exists() should return false instead of null, just like email_exists() does, which is right under it.

See #32444.

#74 @wonderboymusic
9 years ago

In 32639:

Add missing doc blocks to widgets.php.
Cleanup @return values.

See #32444.

#75 @wonderboymusic
9 years ago

In 32640:

Alter visibility of some properties in wpdb:
num_queries is accessed publicly in core.
num_rows is accessed publicly in ms-settings.php.
insert_id is accessed publicly in core.
prefix is accessed publicly in upgrade.php and capabilities.php.

See #32444.

#76 @wonderboymusic
9 years ago

In 32641:

Add missing/alter existing doc blocks for wp-db.php.

See #32444.

#77 @wonderboymusic
9 years ago

In 32642:

Add @global annotations for wp-admin/*.

See #32444.

#78 @wonderboymusic
9 years ago

In 32643:

Add @global annotations to (the rest of the?) wp-admin/* files.

Does not include list table file changes.

See #32444.

#79 @wonderboymusic
9 years ago

In 32650:

Add @static* annotations where they are missing.
Initialize all static vars that are not, most to null.

See #32444.

#80 @wonderboymusic
9 years ago

In 32652:

Add missing annotations to ajax-actions.php`

See #32444.

#81 @wonderboymusic
9 years ago

In 32654:

Add missing doc blocks to wp-admin/includes/*.
Fix some egregious uses of tabbing.
Some functions can simply return apply_filters(...) instead of setting a variable that is immediately returned.

See #32444.

#82 @wonderboymusic
9 years ago

In 32655:

Add (more) missing doc blocks to wp-admin/includes/*.

See #32444.

#83 @wonderboymusic
9 years ago

In 32656:

Add @access annotations to methods that have no doc block in wp-admin/includes/*.
Makes it easier to search for no doc blocks via }[\n\t\r ]+(protected|private|public).

See #32444.

#84 @wonderboymusic
9 years ago

In 32657:

After [32656], add @access annotations to methods that have no doc block in wp-includes/*.
Makes it easier to search for no doc blocks via }[\n\t\r ]+(protected|private|public).

See #32444.

#85 @wonderboymusic
9 years ago

In 32672:

Add doc blocks to functions that are missing them.
If the function has no need for @param or @return, do an archeaological dig to find @since.

See #32444.

#86 follow-up: @johnjamesjacoby
9 years ago

r32596 is causing breakage for me using wp_editor() theme-side.

Fatal error: Call to a member function do_items() on a non-object in /srv/www/wordpress-develop/src/wp-includes/functions.wp-styles.php on line 64

#87 in reply to: ↑ 86 @ocean90
9 years ago

Replying to johnjamesjacoby:

r32596 is causing breakage for me using wp_editor() theme-side.

Fatal error: Call to a member function do_items() on a non-object in /srv/www/wordpress-develop/src/wp-includes/functions.wp-styles.php on line 64

See #32541.

#88 @wonderboymusic
9 years ago

In 32728:

After [32596] and [32597], ensure that wp_scripts|styles() is called to ensure an instance is created of WP_Scripts|Styles() before calling ->do_items().

See #32444.

#89 @wonderboymusic
9 years ago

In 32730:

Don't loosely compare functions that return bool against a literal bool.

See #32444.

#90 @wonderboymusic
9 years ago

In 32731:

Add the proper access modifier to _init_caps() in WP_User. Add __call() for BC.

See #32444.

#91 follow-up: @wonderboymusic
9 years ago

In 32732:

WP_Customize_Setting::is_current_blog_previewed() should only return false, not false or void. The one invocation of the method only loosely checks the return value.

See #32444.

#92 @wonderboymusic
9 years ago

In 32733:

$status shouldn't be loosely compared to true in wp_xmlrpc_server::wp_deleteComment().
$initial shouldn't be loosely compared to true in get_calendar().
current_user_can() shouldn't be loosely compared to false in kses_init()
$get_all shouldn't be loosely compared to true in get_blog_details().
is_array() and in_array() shouldn't be loosely compared in wpmu_validate_user_signup().
$result should by strictly compared in check_ajax_referer().
wp_verify_nonce() should by strictly compared in _show_post_preview().
is_user_logged_in() should not be loosly compared against false in wp-signup.php.

See #32444.

#93 @wonderboymusic
9 years ago

In 32734:

Fix some malformed doc blocks in Custom_Background.

See #32444.

#94 @wonderboymusic
9 years ago

In 32735:

Fix some malformed doc blocks in Custom_Image_Header.

See #32444.

#95 @wonderboymusic
9 years ago

In 32736:

In WP_Comments_List_Table::column_comment(), $post and $the_comment_status are unused, as is the $comment_status global.

See #32444.

#96 @wonderboymusic
9 years ago

In 32737:

In WP_Media_List_Table::display_rows(), get_the_terms() can return WP_Error, so its return value should be checked before traversing.

See #32444.

#97 @wonderboymusic
9 years ago

In 32738:

In WP_Posts_List_Table::single_row():

  • get_the_terms() can return WP_Error, so its return value should be checked before traversing.
  • Correct the @param doc blocks

See #32444.

#98 @wonderboymusic
9 years ago

In 32739:

In WP_Terms_List_Table::display_rows_or_placeholder():

  • get_terms() can return WP_Error, so its return value should be checked before traversing.
  • The 2nd call to get_terms() can be removed, it is redundant #OPTIMIZATION

See #32444.

#99 in reply to: ↑ 91 @jorbin
9 years ago

Replying to wonderboymusic:

In 32732:

WP_Customize_Setting::is_current_blog_previewed() should only return false, not false or void. The one invocation of the method only loosely checks the return value.

See #32444.

This broke the unit tests. https://travis-ci.org/aaronjorbin/develop.wordpress/builds/66576551

#100 @wonderboymusic
9 years ago

In 32800:

if is a statment, not a function.

See #32444.

#101 @wonderboymusic
9 years ago

In 32871:

Add access modifier to WP_Upgrader::clear_destination()

See #32444.

#102 @wonderboymusic
9 years ago

In 32872:

Add access modifier to WP_Customize_Nav_Menu_Control::json()

See #32444.

#103 @wonderboymusic
9 years ago

In 32873:

Add access modifier to WP_Customize_Nav_Menu_Item_Control::json()

See #32444.

#104 @wonderboymusic
9 years ago

In 32874:

Customizer et al, use elseif in PHP, not else if.
This was corrected via brute force in [31090].

See #32444.

#105 @wonderboymusic
9 years ago

In 32875:

Add missing access modifiers to WP_Customize_Nav_Menus.

See #32444.

#106 @wonderboymusic
9 years ago

In 32876:

Add missing access modifier to WP_Customize_Nav_Menus_Panel::wp_nav_menu_manage_columns().

See #32444.

#107 @wonderboymusic
9 years ago

In 32877:

Add missing access modifier to WP_Customize_Sidebar_Section::json().

See #32444.

#108 @wonderboymusic
9 years ago

In 32878:

Add missing access modifiers in class-wp-customize-setting.php.

See #32444.

#109 @wonderboymusic
9 years ago

In 32938:

Remove unused code from WP_MS_Sites_List_Table::display_rows().

See #32444.

#110 @wonderboymusic
9 years ago

In 32939:

Remove unused code from WP_Press_This::html().

See #32444.

#111 @wonderboymusic
9 years ago

In 32940:

prep_atom_text_construct() and before_last_bar() should strictly check against false when using str(r)?pos().

Sidenote: there's a function named before_last_bar.

See #32444.

#112 @wonderboymusic
9 years ago

In 32941:

WP_Rewrite::add_rule() should strictly check against false when using strpos().

See #32444.

#113 @wonderboymusic
9 years ago

In 32942:

wpmu_validate_user_signup() should strictly check against false when using strpos().

See #32444.

#114 @dd32
9 years ago

In 32950:

Remove an undeeded space concatenation from wpmu_validate_user_signup().
This was previously used to prevent strpos() returning 0, which is not needed after r32942.
See #32444

#115 @wonderboymusic
9 years ago

In 32961:

Declare visibility for WP_Locale methods.

See #32444.

#116 @wonderboymusic
9 years ago

In 32962:

In WP_Filesystem_Base::chdir|chgrp|chmod() (all mock abstract methods), modify @return to include string so that subclass @returns match.

See #32444.

#117 @wonderboymusic
9 years ago

In 32963:

Some doc blocks should use bool instead of true|false

See #32444.

#118 @wonderboymusic
9 years ago

In 32964:

For doc block types, favor bool over the few remaining booleans

See #32444.

#119 @wonderboymusic
9 years ago

In 32965:

ob_get_contents() followed by ob_end_clean() can be replaced by ob_get_clean().

See #32444.

#120 follow-up: @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

Something is busted with Scrutinizer itself:
https://scrutinizer-ci.com/g/staylor/WordPress/inspections/c94a164a-e140-4bd1-a266-c0f1df0f19ee

Let's call this done for 4.3. If I get it running again, and I find some flagrant code errors (variables used that aren't set, unused code, missing access modifiers, wrong types for @params, etc) - I'll post them here.

#121 in reply to: ↑ 120 @netweb
9 years ago

Replying to wonderboymusic:

Something is busted with Scrutinizer itself:
https://scrutinizer-ci.com/g/staylor/WordPress/inspections/c94a164a-e140-4bd1-a266-c0f1df0f19ee

I just bumped into this, no idea if it would actually help in fixing the above, SSH'ing into the build session!

https://scrutinizer-ci.com/docs/troubleshooting/ssh_access_to_build

#122 @dd32
9 years ago

In 33601:

Function documentation: Fix a broken docbock introduced with [32642].
See #32444.

#123 @SergeyBiryukov
8 years ago

In 35489:

Docs: After [32654], remove duplicate @param tag in WP_List_Table::set_pagination_args() DocBlock.

Add @since tag.

Props bobbingwide.
See #32444.

#124 in reply to: ↑ 27 @skithund
8 years ago

Replying to wonderboymusic:

In 32545:

When calling unset(), it is unnecessary to immediately precede it with a call to isset().

See #32444.

After this #25649 is happening again.

Note: See TracTickets for help on using tickets.