| Conditions | 8 |
| Paths | 10 |
| Total Lines | 52 |
| Code Lines | 28 |
| Lines | 52 |
| Ratio | 100 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 48 | function _s_entry_footer() { |
||
| 49 | // Hide category and tag text for pages. |
||
| 50 | if ( 'post' === get_post_type() ) { |
||
|
1 ignored issue
–
show
|
|||
| 51 | /* translators: used between list items, there is a space after the comma */ |
||
| 52 | $categories_list = get_the_category_list( esc_html__( ', ', '_s' ) ); |
||
|
2 ignored issues
–
show
|
|||
| 53 | if ( $categories_list ) { |
||
| 54 | /* translators: 1: list of categories. */ |
||
| 55 | printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', '_s' ) . '</span>', $categories_list ); // WPCS: XSS OK. |
||
| 56 | } |
||
| 57 | |||
| 58 | /* translators: used between list items, there is a space after the comma */ |
||
| 59 | $tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', '_s' ) ); |
||
|
2 ignored issues
–
show
|
|||
| 60 | if ( $tags_list ) { |
||
| 61 | /* translators: 1: list of tags. */ |
||
| 62 | printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', '_s' ) . '</span>', $tags_list ); // WPCS: XSS OK. |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { |
||
|
4 ignored issues
–
show
|
|||
| 67 | echo '<span class="comments-link">'; |
||
| 68 | comments_popup_link( |
||
|
1 ignored issue
–
show
|
|||
| 69 | sprintf( |
||
| 70 | wp_kses( |
||
|
1 ignored issue
–
show
|
|||
| 71 | /* translators: %s: post title */ |
||
| 72 | __( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', '_s' ), |
||
|
1 ignored issue
–
show
|
|||
| 73 | array( |
||
| 74 | 'span' => array( |
||
| 75 | 'class' => array(), |
||
| 76 | ), |
||
| 77 | ) |
||
| 78 | ), |
||
| 79 | get_the_title() |
||
|
1 ignored issue
–
show
|
|||
| 80 | ) |
||
| 81 | ); |
||
| 82 | echo '</span>'; |
||
| 83 | } |
||
| 84 | |||
| 85 | edit_post_link( |
||
|
1 ignored issue
–
show
|
|||
| 86 | sprintf( |
||
| 87 | wp_kses( |
||
| 88 | /* translators: %s: Name of current post. Only visible to screen readers */ |
||
| 89 | __( 'Edit <span class="screen-reader-text">%s</span>', '_s' ), |
||
| 90 | array( |
||
| 91 | 'span' => array( |
||
| 92 | 'class' => array(), |
||
| 93 | ), |
||
| 94 | ) |
||
| 95 | ), |
||
| 96 | get_the_title() |
||
| 97 | ), |
||
| 98 | '<span class="edit-link">', |
||
| 99 | '</span>' |
||
| 100 | ); |
||
| 103 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.