All Projects → benas → Jql

benas / Jql

Licence: mit
Java code analysis and linting with SQL

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Jql

Spotbugs
SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.
Stars: ✭ 2,569 (+1635.81%)
Mutual labels:  linter, code-analysis
lancer
Turn your python code into a hideous mess. Ever heard of Black? This is the opposite.
Stars: ✭ 179 (+20.95%)
Mutual labels:  linter, code-analysis
Bodyclose
Analyzer: checks whether HTTP response body is closed and a re-use of TCP connection is not blocked.
Stars: ✭ 181 (+22.3%)
Mutual labels:  linter, 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 (-75.68%)
Mutual labels:  linter, code-analysis
Pmd
An extensible multilanguage static code analyzer.
Stars: ✭ 3,667 (+2377.7%)
Mutual labels:  linter, code-analysis
Sonar Kotlin
SonarQube plugin for Kotlin
Stars: ✭ 412 (+178.38%)
Mutual labels:  linter, code-analysis
node-lintspaces
A validator for checking different kinds of whitespaces in your files.
Stars: ✭ 31 (-79.05%)
Mutual labels:  linter, code-analysis
Wotan
Pluggable TypeScript and JavaScript linter
Stars: ✭ 271 (+83.11%)
Mutual labels:  linter, code-analysis
Coala Bears
Bears for coala
Stars: ✭ 276 (+86.49%)
Mutual labels:  linter, code-analysis
Credo
A static code analysis tool for the Elixir language with a focus on code consistency and teaching.
Stars: ✭ 4,144 (+2700%)
Mutual labels:  linter, code-analysis
Eslint Plugin Sonarjs
SonarJS rules for ESLint
Stars: ✭ 458 (+209.46%)
Mutual labels:  linter, code-analysis
Errcheck
errcheck checks that you checked errors.
Stars: ✭ 1,763 (+1091.22%)
Mutual labels:  linter
Mypy
Optional static typing for Python
Stars: ✭ 11,995 (+8004.73%)
Mutual labels:  linter
Ansible Lint Action
GitHub Action for running ansible-lint as part of your workflows! [ https://github.com/marketplace/actions/ansible-lint ]
Stars: ✭ 124 (-16.22%)
Mutual labels:  linter
Tsqllint
Configurable linting for TSQL
Stars: ✭ 123 (-16.89%)
Mutual labels:  linter
Protolint
A pluggable linter and fixer to enforce Protocol Buffer style and conventions.
Stars: ✭ 142 (-4.05%)
Mutual labels:  linter
Nitpick
Enforce the same settings across multiple language-independent projects
Stars: ✭ 134 (-9.46%)
Mutual labels:  linter
Liche
Fast Link Checker for Markdown and HTML in Go
Stars: ✭ 123 (-16.89%)
Mutual labels:  linter
Feram
Feram finds & fixes bugs in your commits
Stars: ✭ 122 (-17.57%)
Mutual labels:  code-analysis
Ycmd
A code-completion & code-comprehension server
Stars: ✭ 1,575 (+964.19%)
Mutual labels:  code-analysis

MIT license Build Status Development Stage

Important note: This project is in early stage. It is published for evaluation purpose with your help! Please give it a try and send us your feedback, we would love to hear your thoughts!

About JQL

JQL (Java Query Language) makes it possible to query Java source code with SQL. This allows you to answer questions like:

  • Is there any class that has no unit tests?
  • What is the longest class name?
  • Is there an interface with more than 20 methods?

This repository provides a static analysis tool that gives you precious insights on your code base in order to improve its quality.

How does it work?

JQL engine creates a relational database from a Java code base. Once you have created the relational database, you can query it with standard SQL. The relational model has been designed to be intuitive, natural and easy to understand and query. Here are the core entities and relations:

Entities

EDiagram

Relations

RDiagram

You can find a complete description of the database schema here.

Examples of queries

Find interfaces with more than 20 methods
SELECT i.NAME as name, COUNT(m.ID) as nbMethods
FROM INTERFACE i, METHOD m
WHERE m.TYPE_ID = i.ID GROUP BY i.ID HAVING COUNT(m.ID) > 20;
Find classes with more than 5 constructors
SELECT c.NAME as name, COUNT(c.ID) as nbConstructors
FROM CLASS c, CONSTRUCTOR co
WHERE co.TYPE_ID = c.ID GROUP BY c.NAME HAVING COUNT(c.ID) > 5;
Find methods with more than 5 parameters
SELECT t.NAME as typeName, m.NAME as methodName, COUNT(m.ID) as nbParams
FROM TYPE t, METHOD m, PARAMETER p
WHERE p.METHOD_ID = m.ID and m.TYPE_ID = t.ID
GROUP BY m.ID HAVING COUNT(m.ID) > 5;
Find the top 10 longest class names:
SELECT name, LENGTH(name) as length from CLASS ORDER BY length DESC LIMIT 10;

You can find some real world examples on popular open source projects here.

How to get started ?

JQL engine is distributed as a single executable jar that creates a self-contained serverless Sqlite relational database from your Java code base:

java -jar jql-core-0.1.jar /path/to/project/to/analyse /path/to/database/directory

This command will index your code and create a file named jql.db in the specified directory.

For maven based projects, just run the following command in the root directory of the project to analyse:

mvn io.github.benas:jql-maven-plugin:index

The jql.db file will be created in the target directory.

Once you are done, you can open the jql.db file with your favorite SQL client and start writing queries.

You can find all details about how to get started here.

How to contribute?

Since the project is still a PoC, we are not yet focused on the quality of the code base. The main goal for the moment is to see if the relational model is adequate for Java code analysis and linting.

If you want to contribute, please consider the tool as a black box for now.

Any suggestion or improvement of the relational model is very welcome!

You can try to index a code base (or download a pre-indexed database sample) and write some queries. If there is a question you cannot answer, you have certainly found a way to improve the current model! So please open an issue with your question and this would be a great contribution!

Credits

  • JQL tools use JavaParser to parse Java code and transform it into a relational model.

  • JQL tools use Sqlite to store Java code model in a relational database.

License

JQL tools are released under the MIT license:

The MIT License

Copyright (c) 2016, Mahmoud Ben Hassine ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
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].