Merge lp:~dholbach/click-reviewers-tools/1364449 into lp:click-reviewers-tools

Proposed by Daniel Holbach
Status: Merged
Approved by: Jamie Strandboge
Approved revision: 236
Merged at revision: 236
Proposed branch: lp:~dholbach/click-reviewers-tools/1364449
Merge into: lp:click-reviewers-tools
Diff against target: 80 lines (+19/-9)
4 files modified
bin/click-review (+6/-4)
clickreviews/modules.py (+7/-3)
clickreviews/tests/test_modules.py (+3/-1)
debian/changelog (+3/-1)
To merge this branch: bzr merge lp:~dholbach/click-reviewers-tools/1364449
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Approve
Review via email: mp+233088@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Looks good, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/click-review'
2--- bin/click-review 2014-09-01 14:52:33 +0000
3+++ bin/click-review 2014-09-02 16:33:39 +0000
4@@ -88,15 +88,17 @@
5 #
6 section = module.replace('cr_', '')
7 review = modules.init_main_class(module, self.click_fn)
8- review.do_checks()
9- self.results[section] = review.click_report
10- return section
11+ if review:
12+ review.do_checks()
13+ self.results[section] = review.click_report
14+ return None
15
16 def run_all_checks(self):
17 if self.args.sdk:
18 for module in self.cr_modules:
19 section = self._run_module_checks(module)
20- self._report_module(section)
21+ if section:
22+ self._report_module(section)
23 else:
24 for module in self.cr_modules:
25 self._run_module_checks(module)
26
27=== modified file 'clickreviews/modules.py'
28--- clickreviews/modules.py 2014-08-27 17:16:31 +0000
29+++ clickreviews/modules.py 2014-09-02 16:33:39 +0000
30@@ -48,11 +48,13 @@
31 module_name))
32
33 classes = inspect.getmembers(module, inspect.isclass)
34- find_main_class = lambda a: a[0].startswith('Click') and \
35+ find_cr_class = lambda a: a[0].startswith('Click') and \
36 not a[0].endswith('Exception') and \
37 a[1].__module__ == module_name
38- main_class = list(filter(find_main_class, classes))
39- init_object = getattr(module, main_class[0][0])
40+ cr_class = list(filter(find_cr_class, classes))
41+ if not cr_class:
42+ return None
43+ init_object = getattr(module, cr_class[0][0])
44 return init_object
45
46
47@@ -64,4 +66,6 @@
48 '''
49
50 init_object = find_main_class(module_name)
51+ if not init_object:
52+ return None
53 return init_object(click_file)
54
55=== modified file 'clickreviews/tests/test_modules.py'
56--- clickreviews/tests/test_modules.py 2014-08-27 17:18:45 +0000
57+++ clickreviews/tests/test_modules.py 2014-09-02 16:33:39 +0000
58@@ -26,4 +26,6 @@
59 review = modules.find_main_class(module_name)
60 if review:
61 count += 1
62- self.assertEqual(count, len(self.cr_modules))
63+ self.assertEqual(count, len(self.cr_modules),
64+ 'Not all files in clickreviews/cr_*.py contain '
65+ 'classes named Click*Review.')
66
67=== modified file 'debian/changelog'
68--- debian/changelog 2014-09-01 14:37:20 +0000
69+++ debian/changelog 2014-09-02 16:33:39 +0000
70@@ -4,8 +4,10 @@
71 into its own module, add tests for it.
72 * Refactor bin/click-review to make it easier to extend.
73 * Add --sdk option, so the SDK can start using it. (LP: #1363857)
74+ * Safeguard against broken clickreviews check modules, or modules that are
75+ still in development. (LP: #1364449)
76
77- -- Daniel Holbach <daniel.holbach@ubuntu.com> Wed, 27 Aug 2014 16:22:03 +0200
78+ -- Daniel Holbach <daniel.holbach@ubuntu.com> Tue, 02 Sep 2014 18:31:50 +0200
79
80 click-reviewers-tools (0.9) utopic; urgency=medium
81

Subscribers

People subscribed via source and target branches