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 Python utility / library to sort imports.

Read Latest Documentation - Browse GitHub Code Repository isort your imports, so you don't have to. isort is a Python utility / library to sort import

Python Code Quality Authority 5.5k Jan 06, 2023
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
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
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
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
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
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
The strictest and most opinionated python linter ever!

wemake-python-styleguide Welcome to the strictest and most opinionated python linter ever. wemake-python-styleguide is actually a flake8 plugin with s

wemake.services 2.1k Jan 05, 2023
Data parsing and validation using Python type hints

pydantic Data validation and settings management using Python type hinting. Fast and extensible, pydantic plays nicely with your linters/IDE/brain. De

Samuel Colvin 12.1k Jan 05, 2023
Auto-generate PEP-484 annotations

PyAnnotate: Auto-generate PEP-484 annotations Insert annotations into your source code based on call arguments and return types observed at runtime. F

Dropbox 1.4k Dec 26, 2022
Print a directory tree structure in your Python code.

directory-structure Print a directory tree structure in your Python code. Download You can simply: pip install directory-structure Or you can also: Cl

Gabriel Stork 45 Dec 19, 2022
fixup: Automatically add and remove python import statements

fixup: Automatically add and remove python import statements The goal is that running fixup my_file.py will automatically add or remove import stateme

2 May 08, 2022
Collection of library stubs for Python, with static types

typeshed About Typeshed contains external type annotations for the Python standard library and Python builtins, as well as third party packages as con

Python 3.3k 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
TidyPy is a tool that encapsulates a number of other static analysis tools and makes it easy to configure, execute, and review their results.

TidyPy Contents Overview Features Usage Docker Configuration Ignoring Issues Included Tools Included Reporters Included Integrations Extending TidyPy

Jason Simeone 33 Nov 27, 2022
Robocop is a tool that performs static code analysis of Robot Framework code.

Robocop Introduction Documentation Values Requirements Installation Usage Example Robotidy FAQ Watch our talk from RoboCon 2021 about Robocop and Robo

marketsquare 132 Dec 29, 2022
Guesslang detects the programming language of a given source code

Detect the programming language of a source code

Y. SOMDA 618 Dec 29, 2022
A simple stopwatch for measuring code performance with static typing.

A simple stopwatch for measuring code performance. This is a fork from python-stopwatch, which adds static typing and a few other things.

Rafael 2 Feb 18, 2022
Find dead Python code

Vulture - Find dead code Vulture finds unused code in Python programs. This is useful for cleaning up and finding errors in large code bases. If you r

Jendrik Seipp 2.4k Jan 03, 2023
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