Conditions | 1 |
Paths | 1 |
Total Lines | 73 |
Code Lines | 13 |
Lines | 73 |
Ratio | 100 % |
Changes | 7 | ||
Bugs | 0 | Features | 4 |
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 |
||
14 | View Code Duplication | protected function configure() |
|
|
|||
15 | { |
||
16 | parent::configure(); |
||
17 | $this |
||
18 | ->setName('torrent-list') |
||
19 | ->setAliases(['tl']) |
||
20 | ->setDescription('List torrents') |
||
21 | ->addOption('name', null, InputOption::VALUE_OPTIONAL, 'Sort by torrent name (regexp)') |
||
22 | ->addOption('age', null, InputOption::VALUE_OPTIONAL, 'Sort by torrent age, ex. \'>1 <5\'') |
||
23 | ->addOption('sort', null, InputOption::VALUE_OPTIONAL, 'Sort by column number', 4) |
||
24 | ->addOption('limit', null, InputOption::VALUE_OPTIONAL, 'Limit torrent list') |
||
25 | ->setHelp(<<<EOT |
||
26 | ## List torrents |
||
27 | |||
28 | You can list torrents from transmission with `torrent-list` command: |
||
29 | ``` |
||
30 | transmission-cli torrent-list [--sort=column_number] [--name='name'] [--age='>0'] [--limit=10] |
||
31 | ``` |
||
32 | |||
33 | **List columns:** |
||
34 | |||
35 | - Name |
||
36 | - Id - need for `torrent-remove` command |
||
37 | - Age - days from torrent done date |
||
38 | - Size - size of downloaded data |
||
39 | - Uploaded - size of uploaded data |
||
40 | - Per day - average uploaded GB per day |
||
41 | |||
42 | |||
43 | #### Sorting list |
||
44 | |||
45 | You can sort torrents by `Per day` column and estimate unpopular torrents: |
||
46 | ``` |
||
47 | transmission-cli torrent-list --sort=6 |
||
48 | ``` |
||
49 | |||
50 | For reverse sort ordering, add `-` to column number: |
||
51 | ``` |
||
52 | transmission-cli torrent-list --sort=-6 |
||
53 | ``` |
||
54 | |||
55 | |||
56 | #### Filtering torrent list |
||
57 | |||
58 | **By age:** |
||
59 | ``` |
||
60 | transmission-cli torrent-list --age '>10' |
||
61 | transmission-cli torrent-list --age '< 20' |
||
62 | transmission-cli torrent-list --age '>0 <5' |
||
63 | ``` |
||
64 | |||
65 | **By name:** |
||
66 | You can use simple regular expression except `.` and `/` symbols. |
||
67 | |||
68 | Filter FullHD series: |
||
69 | ``` |
||
70 | transmission-cli torrent-list --name 'season*1080*' |
||
71 | ``` |
||
72 | |||
73 | Filter all mkv and avi: |
||
74 | ``` |
||
75 | transmission-cli torrent-list --name '.mkv|.avi' |
||
76 | ``` |
||
77 | |||
78 | #### Limiting torrent list |
||
79 | |||
80 | Output 10 worst torrents: |
||
81 | ``` |
||
82 | transmission-cli torrent-list --sort=6 --limit 10 |
||
83 | ``` |
||
84 | EOT |
||
85 | ); |
||
86 | } |
||
87 | |||
115 |
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.