All Projects → yinwang0 → Pysonar2

yinwang0 / Pysonar2

Licence: apache-2.0
PySonar2: an advanced semantic indexer for Python

Programming Languages

python
139335 projects - #7 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pysonar2

Bodyclose
Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.
Stars: ✭ 181 (-83.15%)
Mutual labels:  static-analysis, code-analysis
swap-detector
A library for detecting swapped arguments in function calls, and a Clang Static Analyzer plugin used to demonstrate the library.
Stars: ✭ 19 (-98.23%)
Mutual labels:  static-analysis, code-analysis
Spotbugs
SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.
Stars: ✭ 2,569 (+139.2%)
Mutual labels:  static-analysis, code-analysis
Find Sec Bugs
The SpotBugs plugin for security audits of Java web applications and Android applications. (Also work with Kotlin, Groovy and Scala projects)
Stars: ✭ 1,748 (+62.76%)
Mutual labels:  static-analysis, code-analysis
Pmd
An extensible multilanguage static code analyzer.
Stars: ✭ 3,667 (+241.43%)
Mutual labels:  static-analysis, code-analysis
Nodejsscan
nodejsscan is a static security code scanner for Node.js applications.
Stars: ✭ 1,874 (+74.49%)
Mutual labels:  static-analysis, code-analysis
Larastan
⚗️ Adds code analysis to Laravel improving developer productivity and code quality.
Stars: ✭ 3,554 (+230.91%)
Mutual labels:  static-analysis, code-analysis
Forbidden Apis
Policeman's Forbidden API Checker
Stars: ✭ 216 (-79.89%)
Mutual labels:  static-analysis, code-analysis
Wotan
Pluggable TypeScript and JavaScript linter
Stars: ✭ 271 (-74.77%)
Mutual labels:  static-analysis, code-analysis
static-code-analysis-plugin
A plugin to simplify Static Code Analysis on Gradle. Not restricted to, but specially useful, in Android projects, by making sure all analysis can access the SDK classes.
Stars: ✭ 36 (-96.65%)
Mutual labels:  static-analysis, code-analysis
Radon
Various code metrics for Python code
Stars: ✭ 1,193 (+11.08%)
Mutual labels:  static-analysis, code-analysis
Eslint Plugin Sonarjs
SonarJS rules for ESLint
Stars: ✭ 458 (-57.36%)
Mutual labels:  static-analysis, code-analysis
Spoon
Spoon is a metaprogramming library to analyze and transform Java source code (up to Java 15). 🥄 is made with ❤️, 🍻 and ✨. It parses source files to build a well-designed AST with powerful analysis and transformation API.
Stars: ✭ 1,078 (+0.37%)
Mutual labels:  static-analysis, code-analysis
Rubysonar
an advanced semantic indexer for Ruby
Stars: ✭ 175 (-83.71%)
Mutual labels:  static-analysis, code-analysis
PhpCodeAnalyzer
PhpCodeAnalyzer scans codebase and analyzes which non-built-in php extensions used
Stars: ✭ 91 (-91.53%)
Mutual labels:  static-analysis, code-analysis
Credo
A static code analysis tool for the Elixir language with a focus on code consistency and teaching.
Stars: ✭ 4,144 (+285.85%)
Mutual labels:  static-analysis, code-analysis
Php Language Server
PHP Implementation of the VS Code Language Server Protocol 🆚↔🖥
Stars: ✭ 1,019 (-5.12%)
Mutual labels:  static-analysis, code-analysis
Phpqa
Docker image that provides static analysis tools for PHP
Stars: ✭ 853 (-20.58%)
Mutual labels:  static-analysis
Torrenter
Simple nodejs package to download torrents using torrent-indexer and webtorrent, especially movie and series.
Stars: ✭ 42 (-96.09%)
Mutual labels:  index
Janett
Java to C#.Net Translator
Stars: ✭ 8 (-99.26%)
Mutual labels:  code-analysis

PySonar2 - an advanced semantic indexer for Python

PySonar2 is a semantic indexer library for Python, designed for batch processing of large code bases.

To create high accuracy and quality index of Python, which is very dynamic language, PySonar2 performs (costly) whole-project interprocedural analysis to infer types of variables, parameters and functions. Because of this, PySonar2 generally produces better index than Python IDEs (such as PyCharm etc.), while at the same time sacraficing real-time indexing abilities of IDEs.

PySonar2 has been the underlying indexing engine for several large-scale code navigation services, such as Google's internal Code Search service, Sourcegraph.com and Insight.io (now part of Elasticsearch). It has been used to index millions of lines of Python code.

How to build

mvn package

Demo

To have a feel of what PySonar2 produce, you can build a simple code browser of the Python 2.7 standard library with the following command line:

java -jar target/pysonar-<version>.jar /usr/lib/python2.7 ./html

This may take a few minutes depending on your machine. You should find some interactive HTML files inside the html directory after this process. You can move your mouse on the variables and click on them to jump to definitions etc.

Note that this is just a simple demo program based on the library. PySonar2 is not meant to be an end-user tool. It is mainly designed as a library for Python IDEs, developer tools and code search engines, so its interface may not be as appealing as an end-user tool.

If you have problems with it, please feel free to contact me.

System requirements

  • Python 2.7.x
  • Python 3.x
  • Java 8+
  • maven

Environment variables

PySonar2 uses CPython's built-in ast package to parse Python code, so please make sure you have python or python3 installed and pointed to by the PATH environment variable. If you have them in different names, please make symbol links.

PYTHONPATH environment variable is used for locating the Python standard libraries. It is important to point it to the correct Python library, for example

export PYTHONPATH=/usr/lib/python2.7

If this is not set up correctly, references to library code will not be found.

Contribute

You are welcome to make code contributions.

Because of the highly complex and unpublished theory behind PySonar2, things may go wrong easily with even an innocent-looking change. If you hope to contribute to PySonar2, please discuss with me first before making significant changes, otherwise I may not be able to review your changes.

For basic verification, you can run the unit tests. PySonar2 has a basic test framework. You can run the tests using this command:

mvn test

If you modify the code or tests, you need to generate new expected results. Run these command lines:

mvn package -DskipTests
java -classpath target/pysonar-<version>.jar org.yinwang.pysonar.TestInference -generate tests

To write new tests, you just need to write relevant Python code demonstrating your change, put them into a directory named tests/testname.test(test directory name must end with ".test"). Please look at the tests directory for examples.

Please don't expect the tests to catch all bugs. Be very careful :)

License

Apache 2.0 License. See LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].