Metrinome is an all-purpose tool for working with code complexity metrics.

Overview

Lint and Test codecov License: GPL v3 Python 3.9

Overview

Metrinome is an all-purpose tool for working with code complexity metrics. It can be used as both a REPL and API, and includes:

  • Converters to turn C++, Java, and Python code to Control Flow Graphs
  • Metric calculators for NPath, Cyclomatic, and Path Complexity
  • KLEE utilities to automatically analyze C++ code

To get started, follow the guide in the wiki to pull the docker image and jump directly into the REPL.

Links

Comments
  • Unable to convert

    Unable to convert

    Hello, I am having trouble using the convert command. I am simply trying to convert the python example given (for starters) but it keeps saying "Could not get files from: test.py". I am probably missing a trick here. Do you have an idea?

    opened by UsmanGohar 11
  • Converting Java files in a directory

    Converting Java files in a directory

    Describe the bug When running "convert <path_to_directory>", only the filename is passed from do_convert(...) in core/command.py to to_graph(...) in lang_to_cfg/java.py, so "javac <file_name> -d <directory_path>" in to_graph(...) incorrectly searches the user's current directory for the file instead of <path_to_directory>.

    To Reproduce Steps to reproduce the behavior:

    1. Make a directory with Java files in src
    2. Run the REPL
    3. Execute "convert <path_to_directory>"

    Temporary fix In do_convert(...) in core/command.py, I concatenated the path with the filename to to_graph(...) in lang_to_cfg/java.py which fixes this issue, although I am not sure if it creates other issues.

    Screenshots Before: Screen Shot 2021-06-04 at 11 04 26 AM

    After: Screen Shot 2021-06-04 at 11 04 59 AM

    bug 
    opened by desparza22 3
  • Converted graphs not showing

    Converted graphs not showing

    Thank you for sharing this project! I didn't list this as a bug because I wasn't sure if maybe I was doing something wrong. I seem to run into trouble inside of the Path Complexity REPL. I was able to convert the first file I tried (a Java file), but I noticed the graph said "Lines of code: None", so I decided to try a second to see if maybe there was an issue with the first. Converting the second file resulted in "Converted Successfully", but then unlike the first, no name for the graph was printed to the terminal. I tried "list graphs", and got "No graphs available". The same thing happened when I quit and tried again. Maybe it is an issue with the file itself, but it is a very simple file in terms of structure, and very similar to the first which converted successfully. The only difference between the two is that the first calls static functions whereas the second creates an object and calls functions on the object. All functions and variables in each file are contained within a single object. Thank you for your help! Let me know if I can further explain any of these issues.

    opened by desparza22 2
  • show metrics displays a table

    show metrics displays a table

    "show metrics" displays a table similar to the table when "metrics" is called. NOTE: cannot display time since runtime of each complexity eval is not stored

    opened by sdev49 1
  • Bump numpy from 1.19.4 to 1.22.0

    Bump numpy from 1.19.4 to 1.22.0

    Bumps numpy from 1.19.4 to 1.22.0.

    Release notes

    Sourced from numpy's releases.

    v1.22.0

    NumPy 1.22.0 Release Notes

    NumPy 1.22.0 is a big release featuring the work of 153 contributors spread over 609 pull requests. There have been many improvements, highlights are:

    • Annotations of the main namespace are essentially complete. Upstream is a moving target, so there will likely be further improvements, but the major work is done. This is probably the most user visible enhancement in this release.
    • A preliminary version of the proposed Array-API is provided. This is a step in creating a standard collection of functions that can be used across application such as CuPy and JAX.
    • NumPy now has a DLPack backend. DLPack provides a common interchange format for array (tensor) data.
    • New methods for quantile, percentile, and related functions. The new methods provide a complete set of the methods commonly found in the literature.
    • A new configurable allocator for use by downstream projects.

    These are in addition to the ongoing work to provide SIMD support for commonly used functions, improvements to F2PY, and better documentation.

    The Python versions supported in this release are 3.8-3.10, Python 3.7 has been dropped. Note that 32 bit wheels are only provided for Python 3.8 and 3.9 on Windows, all other wheels are 64 bits on account of Ubuntu, Fedora, and other Linux distributions dropping 32 bit support. All 64 bit wheels are also linked with 64 bit integer OpenBLAS, which should fix the occasional problems encountered by folks using truly huge arrays.

    Expired deprecations

    Deprecated numeric style dtype strings have been removed

    Using the strings "Bytes0", "Datetime64", "Str0", "Uint32", and "Uint64" as a dtype will now raise a TypeError.

    (gh-19539)

    Expired deprecations for loads, ndfromtxt, and mafromtxt in npyio

    numpy.loads was deprecated in v1.15, with the recommendation that users use pickle.loads instead. ndfromtxt and mafromtxt were both deprecated in v1.17 - users should use numpy.genfromtxt instead with the appropriate value for the usemask parameter.

    (gh-19615)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Getting the message

    Getting the message "Converted without errors, but no graphs created"

    /app/code > convert /app/Simple2.java

    processing /app/Simple2.java ~~~ CONVERTED SUCCESSFULLY ~~~ Converted without errors, but no graphs created.

    I am getting the following message on trying to convert a simple Java program into the control flow graph.

    Following is the program itself

    public class Simple2 {  
        static void p(){  
              System.out.println("hello");  
              p();  
        }  
      
        public static void main(String[] args) {  
              p();  
        }  
    }  
    
    

    What am I missing ?

    opened by rahulsee 0
Releases(1.1.0)
  • 1.1.0(Jan 9, 2021)

    Updated coverage status checks

    Added tests & improved existing tests

    Refactored graphs and split up into multiple subtypes

    • Created a GenericGraph parent class as well as a Graph interface, which are inherited and implemented by EdgeListGraph, AdjListGraph, and AdjMatGraph.

    Cleaned up klee experiment scripts, creating KleeExperimentHandler for easier experiment modification and creation in the future.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Dec 7, 2020)

  • 0.0.1(Sep 26, 2020)

A system for Python that generates static type annotations by collecting runtime types

MonkeyType MonkeyType collects runtime types of function arguments and return values, and can automatically generate stub files or even add draft type

Instagram 4.1k Jan 02, 2023
A bytecode vm written in python.

CHex A bytecode vm written in python. hex command meaning note: the first two hex values of a CHex program are the magic number 0x01 (offset in memory

1 Aug 26, 2022
Learning source code review, spot vulnerability, find some ways how to fix it.

Learn Source Code Review Learning source code review, spot vulnerability, find some ways how to fix it. WordPress Plugin Authenticated Stored XSS on C

Shan 24 Dec 31, 2022
Calculator Python Package

Calculator Python Package This is a Calculator Package of Python. How To Install The Package? Install packagearinjoyn with pip (Package Installer Of P

Arinjoy_Programmer 1 Nov 21, 2021
Code audit tool for python.

Pylama Code audit tool for Python and JavaScript. Pylama wraps these tools: pycodestyle (formerly pep8) © 2012-2013, Florent Xicluna; pydocstyle (form

Kirill Klenov 966 Dec 29, 2022
ticktock is a minimalist library to profile Python code

ticktock is a minimalist library to profile Python code: it periodically displays timing of running code.

Victor Benichoux 30 Sep 28, 2022
Performant type-checking for python.

Pyre is a performant type checker for Python compliant with PEP 484. Pyre can analyze codebases with millions of lines of code incrementally – providi

Facebook 6.2k Jan 07, 2023
Inspects Python source files and provides information about type and location of classes, methods etc

prospector About Prospector is a tool to analyse Python code and output information about errors, potential problems, convention violations and comple

Python Code Quality Authority 1.7k Dec 31, 2022
Static type checker for Python

Static type checker for Python Speed Pyright is a fast type checker meant for large Python source bases. It can run in a “watch” mode and performs fas

Microsoft 9.4k Jan 07, 2023
coala provides a unified command-line interface for linting and fixing all your code, regardless of the programming languages you use.

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." ― John F. Woods coala provides a

coala development group 3.4k Jan 02, 2023
A static type analyzer for Python code

pytype - ? ✔ Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can: Lint plain Python code, flagging c

Google 4k Dec 31, 2022
Metrinome is an all-purpose tool for working with code complexity metrics.

Overview Metrinome is an all-purpose tool for working with code complexity metrics. It can be used as both a REPL and API, and includes: Converters to

26 Dec 26, 2022
Typical: Fast, simple, & correct data-validation using Python 3 typing.

typical: Python's Typing Toolkit Introduction Typical is a library devoted to runtime analysis, inference, validation, and enforcement of Python types

Sean 170 Dec 26, 2022
An interpreter for the X1 bytecode.

X1 Bytecode Interpreter The X1 Bytecode is bytecode designed for simplicity in programming design and compilation. Bytecode Instructions push

Thanasis Tzimas 1 Jan 15, 2022
An app to show the total number of lines of code written by an user.

Lines of code Have you ever wondered how many lines of code you wrote in github? This tool will calculate it for you! To calculate the total number of

B.Jothin kumar 10 Jan 26, 2022
Checkov is a static code analysis tool for infrastructure-as-code.

Checkov - Prevent cloud misconfigurations during build-time for Terraform, Cloudformation, Kubernetes, Serverless framework and other infrastructure-as-code-languages with Checkov by Bridgecrew.

Bridgecrew 5.1k Jan 03, 2023
Unbearably fast O(1) runtime type-checking in pure Python.

Look for the bare necessities, the simple bare necessities. Forget about your worries and your strife. — The Jungle Book.

1.4k Dec 29, 2022
Run-time type checker for Python

This library provides run-time type checking for functions defined with PEP 484 argument (and return) type annotations. Four principal ways to do type

Alex Grönholm 1.1k Dec 19, 2022
Find usage statistics (imports, function calls, attribute access) for Python code-bases

Python Library stats This is a small library that allows you to query some useful statistics for Python code-bases. We currently report library import

Francisco Massa 13 May 02, 2022
A formatter for Python files

YAPF Introduction Most of the current formatters for Python --- e.g., autopep8, and pep8ify --- are made to remove lint errors from code. This has som

Google 13k Dec 31, 2022