Conditions | 7 |
Total Lines | 69 |
Lines | 0 |
Ratio | 0 % |
Changes | 12 | ||
Bugs | 0 | Features | 2 |
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 | # -*- coding: utf-8 -*- |
||
97 | def create_changelog(repo=None, |
||
98 | username=None, |
||
99 | password=None, |
||
100 | token=None, |
||
101 | milestone=None, |
||
102 | since_tag=None, |
||
103 | until_tag=None, |
||
104 | branch=None, |
||
105 | output_format='changelog', |
||
106 | issue_label_regex='', |
||
107 | pr_label_regex='', |
||
108 | template_file=None, |
||
109 | issue_label_groups=None): |
||
110 | """Create changelog data.""" |
||
111 | # Instantiate Github API |
||
112 | gh = GitHubRepo( |
||
113 | username=username, |
||
114 | password=password, |
||
115 | token=token, |
||
116 | repo=repo, ) |
||
117 | |||
118 | version = until_tag or None |
||
119 | milestone_number = None |
||
120 | closed_at = None |
||
121 | since = None |
||
122 | until = None |
||
123 | version_tag_prefix = 'v' |
||
124 | |||
125 | # Set milestone or from tag |
||
126 | if milestone and not since_tag: |
||
127 | milestone_data = gh.milestone(milestone) |
||
128 | milestone_number = milestone_data['number'] |
||
129 | closed_at = milestone_data['closed_at'] |
||
130 | version = milestone |
||
131 | |||
132 | if version.startswith(version_tag_prefix): |
||
133 | version = version[len(version_tag_prefix):] |
||
134 | |||
135 | elif not milestone and since_tag: |
||
136 | since = gh.tag(since_tag)['tagger']['date'] |
||
137 | if until_tag: |
||
138 | until = gh.tag(until_tag)['tagger']['date'] |
||
139 | closed_at = until |
||
140 | |||
141 | # This returns issues and pull requests |
||
142 | issues = gh.issues( |
||
143 | milestone=milestone_number, |
||
144 | state='closed', |
||
145 | since=since, |
||
146 | until=until, |
||
147 | branch=branch, ) |
||
148 | |||
149 | # Filter by regex if available |
||
150 | filtered_prs = filter_prs_by_regex(issues, pr_label_regex) |
||
151 | filtered_issues = filter_issues_by_regex(issues, issue_label_regex) |
||
152 | |||
153 | # If issue label grouping, filter issues |
||
154 | new_filtered_issues, issue_label_groups = filter_issue_label_groups( |
||
155 | filtered_issues, issue_label_groups) |
||
156 | |||
157 | return format_changelog( |
||
158 | repo, |
||
159 | new_filtered_issues, |
||
160 | filtered_prs, |
||
161 | version, |
||
162 | closed_at=closed_at, |
||
163 | output_format=output_format, |
||
164 | template_file=template_file, |
||
165 | issue_label_groups=issue_label_groups) |
||
166 | |||
225 |