Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 | (function( $ ) { |
||
|
|||
2 | 'use strict'; |
||
3 | |||
4 | jQuery(document).ready(function(){ |
||
5 | |||
6 | jQuery("span.shorten_string").click(function(){ |
||
7 | jQuery(this).toggleClass("full"); |
||
8 | doShortText(jQuery(this)); |
||
9 | }) |
||
10 | |||
11 | jQuery("span.shorten_string").each(function(){ |
||
12 | doShortText(jQuery(this)); |
||
13 | }) |
||
14 | |||
15 | jQuery("#xcloner_regex_exclude").on("focus", function(){ |
||
16 | jQuery("ul.xcloner_regex_exclude_limit li").fadeIn(); |
||
17 | }) |
||
18 | |||
19 | jQuery(".regex_pattern").click(function(){ |
||
20 | jQuery(this).select(); |
||
21 | }) |
||
22 | |||
23 | jQuery(".btn.system_info_toggle").click(function(){ |
||
24 | jQuery(".additional_system_info").toggle(); |
||
25 | }) |
||
26 | |||
27 | jQuery(".nav-tab-wrapper.content li").click(function(e){ |
||
28 | jQuery(".nav-tab-wrapper li a").removeClass("nav-tab-active"); |
||
29 | jQuery(this).find('a').addClass("nav-tab-active"); |
||
30 | jQuery(".nav-tab-wrapper-content .tab-content").removeClass('active'); |
||
31 | jQuery(".nav-tab-wrapper-content "+jQuery(this).find('a').attr('href')).addClass('active'); |
||
32 | |||
33 | e.preventDefault(); |
||
34 | |||
35 | location.hash = jQuery(this).find('a').attr('href')+"_hash"; |
||
36 | |||
37 | }) |
||
38 | |||
39 | var hash = window.location.hash; |
||
40 | if(hash){ |
||
41 | next_tab(hash.replace("_hash","")); |
||
42 | } |
||
43 | }) |
||
44 | |||
45 | /** |
||
46 | * All of the code for your admin-facing JavaScript source |
||
47 | * should reside in this file. |
||
48 | * |
||
49 | * Note: It has been assumed you will write jQuery code here, so the |
||
50 | * $ function reference has been prepared for usage within the scope |
||
51 | * of this function. |
||
52 | * |
||
53 | * This enables you to define handlers, for when the DOM is ready: |
||
54 | * |
||
55 | * $(function() { |
||
56 | * |
||
57 | * }); |
||
58 | * |
||
59 | * When the window is loaded: |
||
60 | * |
||
61 | * $( window ).load(function() { |
||
62 | * |
||
63 | * }); |
||
64 | * |
||
65 | * ...and/or other possibilities. |
||
66 | * |
||
67 | * Ideally, it is not considered best practise to attach more than a |
||
68 | * single DOM-ready or window-load handler for a particular page. |
||
69 | * Although scripts in the WordPress core, Plugins and Themes may be |
||
70 | * practising this, we should strive to set a better example in our own work. |
||
71 | */ |
||
72 | |||
73 | })( jQuery ); |
||
74 | |||
138 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.