Gathering detailed insights and metrics for java-parser
Gathering detailed insights and metrics for java-parser
Gathering detailed insights and metrics for java-parser
Gathering detailed insights and metrics for java-parser
npm install java-parser
2.6.5
Published on 25 Oct 2024
2.6.4
Published on 12 Jul 2024
2.6.0
Published on 22 Feb 2024
v2.5.0
Published on 26 Nov 2023
v2.4.0
Published on 12 Nov 2023
v2.3.1
Published on 04 Sept 2023
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,106 Stars
721 Commits
104 Forks
22 Watching
1 Branches
65 Contributors
Updated on 27 Nov 2024
Java (39.77%)
JavaScript (29.89%)
TypeScript (28.32%)
CSS (1.45%)
HTML (0.46%)
MDX (0.08%)
Shell (0.04%)
Cumulative downloads
Total Downloads
Last day
4.7%
62,472
Compared to previous day
Last week
11.8%
323,502
Compared to previous week
Last month
52.6%
1,280,099
Compared to previous month
Last year
80%
11,245,946
Compared to previous year
3
Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
A Prettier plugin must first parse the source code of the target language into a traversable data structure (Usually an Abstract Syntax Tree) and then print out that data structure in a "pretty" style.
Prettier-Java uses a Java-Parser implemented in JavaScript using the
Chevrotain Parser Building Toolkit for JavaScript.
What this means is that unlike many other Prettier plugins,
prettier-java
has no additional runtime pre-requisites (e.g: Python executable).
It could even be used inside a browser.
This project contains 2 packages:
prettier-plugin-java A plugin for Prettier to format Java code
java-parser A Java Parser using Chevrotain which output a Concrete Syntax Tree
1# Local installation 2npm install prettier-plugin-java --save-dev 3 4# Or globally 5npm install -g prettier prettier-plugin-java
or with yarn:
1# Local installation 2yarn add prettier-plugin-java --dev 3 4# Or globally 5yarn global add prettier prettier-plugin-java
Note: If you want to install the prettier-plugin-java globally, you should also install the prettier package globally.
To reformat all your Java files, you first need to create .prettierrc.yaml
with following content:
1plugins: 2 - prettier-plugin-java
Then run:
1# If you have installed the package locally 2npx prettier --write "**/*.java" 3 4# Or globally 5prettier --write "**/*.java"
To see IDE configuration or other advanced usage: please go to the Advanced Usage section
A neat maven plugin for prettier-java was made by developers from HubSpot.
Add it to the plugins
section of your build
configuration
1<build> 2 <plugins> 3 <plugin> 4 <groupId>com.hubspot.maven.plugins</groupId> 5 <artifactId>prettier-maven-plugin</artifactId> 6 <!-- Find the latest version at https://github.com/jhipster/prettier-java/releases --> 7 <version>0.8</version> 8 </plugin> 9 </plugins> 10</build>
If you would like to use this plugin, we recommend you to check their project as is it well documented.
Prettier-java is currently sorting imports according to the Google Java Style guide.
If you are using an IDE such as IntelliJ, you might want to configure it to match with Prettier-java.
For IntelliJ, you can use this configuration:
You can also import the Checkstyle configuration provided in the next section.
For VSCode with Language Support for Java, you can use this configuration (settings.json
):
1{ 2 "java.completion.importOrder": ["#"] 3}
You can use Prettier in combination with other linter, like Checkstyle.
Here is one Checkstyle Prettier compatible configuration you can use to start with !
You can directly import the config into IntelliJ Idea for instance:
In .prettierrc.yaml
, you can configure the indent:
For using four spaces:
1tabWidth: 4
For more configuration options such as using tabs, maximum line length, and more see https://prettier.io/docs/en/configuration.html.
Contributions are very welcome. See the contribution guide to get started. And the Help Wanted issues.
Special thanks to @thorbenvh8 for creating the original prettier-java
plugin and the associated Java Parser implemented in JavaScript.
We would also like to thank the Chevrotain and Prettier contributors which made this possible.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
18 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 4/17 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More