rickrankin / pynocle Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/pynocle
Automatically exported from code.google.com/p/pynocle
======== Overview ======== Pynocle is a python module and API for the generation of software metrics. It aims to be as dead simple to use as possible. Simply create a pynocle.Monocle object, and call generate_all to generate all supported metrics! In the future, there will be much more configuration available. Currently supported metrics include: * cyclomatic complexity * lines of code (source, comment, blank, total) * test coverage * dependency graphing * coupling measurement * module ranking In the future, additional metrics will be supported. For more information about what metrics mean what, see the Description of Metrics section below. ===== Usage ===== pynocle is meant to be used as a simple API from your own python code. Simply import pynocle, create a Monocle instance, and the generate_all method. That's it! To generate coverage, you can pass a parameterless function (like nose.run) into pynocle.run_with_coverage. Pass any coverage.coverage instance into Monocle.coverdata in order to generate coverage reports. The internal API's are more complex and flexible and we'll be working on exposing that configuration as time goes by. There is no commandline support, though commandline support for pynocle and its individual modules may be added later. ============ Dependencies ============ * Python 2.6 or higher * The docutils module. * For coverage support, requires the coverage module: http://pypi.python.org/pypi/coverage * For dependency graph generation support, requires GraphViz's free software: http://www.graphviz.org/ * For page ranking algorithm, requires numpy. ============ Installation ============ Run setup.py to install pynocle and python dependencies. Make sure you have GraphViz's 'dot' in your application path to use dependency graph visualization features. This will be configurable in the future. ======= Support ======= Please email [email protected] if you have any questions, bugs, or want to help! Fork the Hg repository at http://code.google.com/p/pynocle/ My personal site is at http://www.robg3d.com ========================= License and Contributions ========================= Pynocle is released under the MIT license. Copyright 2011 Robert Galanakis, [email protected]. I owe a huge thanks to Patrick Smacchia and the NDepend (www.ndepend.com) team. NDepend, is a fantastic code analysis tool for .NET, and I owe a large number of the ideas and metrics to them. This project uses a few pieces of code originally developed in pygenie, which measured cyclomatic complexity only. Most of the code has been stripped out and only a few classes remain. There is no functional homepage for the source so I can't link anywhere. ====================== Description of Metrics ====================== A generated metrics report will have more information about software metrics, and links for additional info. See the example output for more info, available here: http://pynocle.googlecode.com/hg/examples/exampleoutput/index.html You can look at any good static analysis tool and wikipedia to get overviews of various code metrics: * http://www.ndepend.com/Metrics.aspx * http://www.aivosto.com/project/help/pm-index.html
Hi,
I very interested by your project but have you ever tested your package?
1/ The setup.py is full of ^M
2/ Wrong setup.py
[~/src/pynocle]$ py2.7.2 setup.py sdist
Traceback (most recent call last):
File "setup.py", line 11, in <module>
version=pynocle.__version__,
AttributeError: 'NoneType' object has no attribute '__version__'
You cannot use your module here.
3/ Your code uses the pynocle module but you install cyclcompl, depgraph,
inheritance, sloc.
Do you want some help to package your module and test it on Linux?
Original issue reported on code.google.com by [email protected]
on 30 Sep 2011 at 9:35
The dependency graph is very basic. Look at working with the coupling data to
enhance the graph.
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:48
Get rid of the shitty plaintext reporting and use an HTML reporter. Ideally
it'd have sortable columns so users can click to sort alphabetically, asc/desc
by metric, etc. This will also make it useful to have relational data, which
will be a big change for the future.
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:52
Right now pynocle imports using __import__. This means code is actually
evaluated, which is a problem for some codebases and a problem in general (to
do most analysis, it shouldn't need to execute the code). Switch things to use
the 'imp' module and duplicate the import logic.
Make sure this has good tests written since it's replacing some core
functionality.
Original issue reported on code.google.com by [email protected]
on 1 Oct 2011 at 4:05
I need someone with a *nix machine to help me make sure this project can be run
on *nix boxes. I'm sure it cannot in some places (such as where WindowsError's
are being caught), but don't have a machine to work with and don't want to set
up a VM right now.
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 3:02
On Mac, os.altsep is None. This leads to TypeErrors when calling
string.replace(os.altsep, os.sep). The patch attached below fixes the issue
beaumont@beaumont:~/pynocle$ hg log -r tip -p
changeset: 90:afaab9ad9d22
tag: tip
user: Chris Beaumont <[email protected]>
date: Wed Jun 13 16:32:31 2012 -0400
summary: Fix bug when handling os.altsep on Macs
diff -r 9dbf4784fcad -r afaab9ad9d22 pynocle/depgraph/rendering.py
--- a/pynocle/depgraph/rendering.py Sun Jun 10 23:15:29 2012 +0000
+++ b/pynocle/depgraph/rendering.py Wed Jun 13 16:32:31 2012 -0400
@@ -68,7 +68,7 @@
#Skip the period on the extension
result = os.path.splitext(outputfilename)[1][1:]
return result
-
+
def render(self, outputfilename,
dotpath=None, overrideformat=None, wait=True, moreargs=()):
"""Renders the dot file at dotpath to outputfilename.
@@ -160,7 +160,7 @@
f.write('digraph G {\n')
for kvp in self.styler.graphsettings().items():
f.write(' %s=%s;\n' % kvp)
-
+
pkgs, modules = self._write_edges(f)
failed = dict((self.styler.nodetext(fname), fname)
for fname in self.failedfiles)
@@ -279,10 +279,10 @@
if not s2:
# We've removed the whole path,
# grab the last dir from the leadingpath that removed it
- s2 = self.leading_path.replace(os.altsep, os.sep).split(os.sep)[-1]
+ s2 = utils.sanitize_altsep(self.leading_path).split(os.sep)[-1]
else:
s2 = os.path.splitdrive(s2)[1]
- s2 = s2.replace(os.sep, '.').replace(os.altsep, '.')
+ s2 = utils.sanitize_altsep(s2).replace(os.sep, '.')
return s2.strip('.')
def weight(self, a, b):
@@ -292,7 +292,7 @@
self.weight_heaviest.
If module b starts with an underscore, assume a high weight.
- If module a starts with module b or vice versa, assume a
+ If module a starts with module b or vice versa, assume a
"""
if b.split('.')[-1].startswith('_'):
# A module that starts with an underscore.
diff -r 9dbf4784fcad -r afaab9ad9d22 pynocle/utils.py
--- a/pynocle/utils.py Sun Jun 10 23:15:29 2012 +0000
+++ b/pynocle/utils.py Wed Jun 13 16:32:31 2012 -0400
@@ -137,12 +137,17 @@
:param leading: If None, cwd.
"""
- leading = (leading or os.getcwd()).replace(os.altsep, os.sep)
- s = os.path.splitext(path.replace(os.altsep, os.sep))[0]
+ leading = sanitize_altsep(leading or os.getcwd())
+ s = os.path.splitext(sanitize_altsep(path))[0]
if s.startswith(leading):
s = s.replace(leading, '')
return s.strip(os.sep)
+def sanitize_altsep(string):
+ if os.altsep:
+ return string.replace(os.altsep, os.sep)
+ else:
+ return string
def rst_to_html(rststr):
from docutils.core import publish_string
Original issue reported on code.google.com by [email protected]
on 13 Jun 2012 at 8:38
Attachments:
Number of subclasses, direct and total
Number of baseclasses, direct and total
Longest inheritance chain
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:30
What steps will reproduce the problem?
1. running test_init on a selected file.
What is the expected output? What do you see instead?
error
What version of the product are you using? On what operating system?
win 7, 32bit
Please provide any additional information below.
Traceback (most recent call last):
File "C:\Users\shawn.kirsch\Desktop\pynocle\test_shawn.py", line 10, in <module>
m = pynocle.Monocle(outputdir = 'exampleoutput' , files_and_folders = 'C:\trunk\RGS_Media\Libraries\Media_Software_Library\Scripts\Development_Branch\MT_Validator\mt_validator.py')
File "C:\Users\shawn.kirsch\Desktop\pynocle\..\pynocle\__init__.py", line 197, in __init__
self.filenames = utils.find_all(files_and_folders)
File "C:\Users\shawn.kirsch\Desktop\pynocle\..\pynocle\utils.py", line 93, in find_all
fa = _FindAll(files_and_folders, pattern)
File "C:\Users\shawn.kirsch\Desktop\pynocle\..\pynocle\utils.py", line 68, in __init__
self.findall(files_and_folders)
File "C:\Users\shawn.kirsch\Desktop\pynocle\..\pynocle\utils.py", line 87, in findall
self.findall(paths)
File "C:\Users\shawn.kirsch\Desktop\pynocle\..\pynocle\utils.py", line 86, in findall
paths = map(lambda x: os.path.join(d, x), os.listdir(d))
WindowsError: [Error 5] Access is denied: '\\Documents and Settings/*.*'
Process terminated with an exit code of 1
Original issue reported on code.google.com by [email protected]
on 26 Sep 2011 at 4:07
The current depgraph is unusable on large codebases. Look at improving
clustering to keep packages together.
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:49
What steps will reproduce the problem?
1. use Monocle(prj_name, report_dir, code_dir).generate_all()
2. open the dependency graph
3. see that because it includes site-package it is:
- huge
- too complex to be readable and therefore useful.
a flag on the Monocle constructor would be the best solution for choosing the
behavior.
Original issue reported on code.google.com by [email protected]
on 28 Jun 2012 at 12:30
Once things are working, add some basic configuration ability to the depgraph
so users can change how things are rendered without having to write their own
renderer.
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:48
Look into what'd be involved in adding a runtime call graph.
http://pycallgraph.slowchop.com/pycallgraph/wiki
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:46
The default.css file does not get copied to the installation directory when
running setup.py install. (The file also seems to be missing when downloading
from PyPI).
Original issue reported on code.google.com by [email protected]
on 13 Jun 2012 at 8:39
Function parameter count (required and optional)
Number of local variables
Original issue reported on code.google.com by [email protected]
on 27 Sep 2011 at 2:41
The problem is that setup.py tries to import pynocle, which obviously doesn't
exist the first time you install it.
Of course you could install it with easy_install maybe, but it's not really the
correct way.
I fixed this and polished a bit the setup.py file in the attached diff..
If you prefer I can clone the project and then send you more "automatic"
patches, because the project is really interesting.
Original issue reported on code.google.com by [email protected]
on 13 Dec 2011 at 11:31
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.