<div dir="ltr">I ran this tool on Keystone and liked the results - the two methods that ranked D should certainly be refactored. It also matched a few methods in openstack/common.<div><br></div><div>But flake8 supports complexity checking already, using mccabe. Just enable complexity checking with:</div><div><br></div><div> $ flake8 --max-complexity 20</div><div><br></div><div>It seems to function about the same as radon + xenon, where a D in that tool is about a --max-complexity of 22. And flake8 obeys our existing tox directives (such as ignoring openstack/common).</div><div><br></div><div>+1 for enabling complexity checking though.<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 16, 2014 at 10:11 PM, Angus Salkeld <span dir="ltr"><<a href="mailto:asalkeld@mirantis.com" target="_blank">asalkeld@mirantis.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hi all<br><br></div>I came across some tools [1] & [2] that we could use to make sure we don't increase our code complexity.<br></div><br></div>Has anyone had any experience with these or other tools?<br><br></div>radon is the underlying reporting tool and xenon is a "monitor" - meaning it will fail if a threshold is reached.<br><br></div>To save you the time:<br>radon cc -nd heat<br>heat/engine/stack.py<br> M 809:4 Stack.delete - E<br> M 701:4 Stack.update_task - D<br>heat/engine/resources/server.py<br> M 738:4 Server.handle_update - D<br> M 891:4 Server.validate - D<br>heat/openstack/common/jsonutils.py<br> F 71:0 to_primitive - D<br>heat/openstack/common/config/generator.py<br> F 252:0 _print_opt - D<br>heat/tests/v1_1/fakes.py<br> M 240:4 FakeHTTPClient.post_servers_1234_action - F<br><br></div>It ranks the complexity from A (best) upwards, the command above (-nd) says only show D or worse.<br></div><div>If you look at these methods they are getting out of hand and are becoming difficult to understand.<br></div><div>I like the idea of having a threshold that says we are not going to just keep adding to the complexity<br></div><div>of these methods.<br></div><div><br></div>This can be enforced with:<br>xenon --max-absolute E heat<br>ERROR:xenon:block "heat/tests/v1_1/fakes.py:240 post_servers_1234_action" has a rank of F<br><br><div><div><div><div><div><div>[1] <a href="https://pypi.python.org/pypi/radon" target="_blank">https://pypi.python.org/pypi/radon</a><br>[2] <a href="https://pypi.python.org/pypi/xenon" target="_blank">https://pypi.python.org/pypi/xenon</a><br><br></div><div>If people are open to this, I'd like to add these to the test-requirements and trial this in Heat<br></div><div>(as part of the pep8 tox target).<br></div><div><br></div><div>Regards<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>Angus<br></div></font></span></div></div></div></div></div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div></div></div>