GithubHelp home page GithubHelp logo

pynocle's Introduction

========
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

pynocle's People

Watchers

 avatar

pynocle's Issues

Wrong setup.py

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

Make an HTML table renderer

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

Replace importing with pseudo importing

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

Add *nix support

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

string.replace(os.altsep, os.sep) crashes on Mac

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:

Add inheritance metrics

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

Access 5 Error

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

Add clustering to depgraph

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

make the metrics ignore site-packages.

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

Add call graph

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

setup.py can't install if not present already

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:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.