Skip to content

Commit

Permalink
Consolidated changes for code formatting and linting
Browse files Browse the repository at this point in the history
- Documentation for contributors implemented
- Google Java Format plugin added
- Google Code Formatter applied
- Instructions on how to format the code added
- Instructions on how to use Linter added
- Checkstyle plugin added
- CheckStyle configuration created
- Changes according to checkstyle request
- Checkstyle configuration updated
  • Loading branch information
mulla028 committed Nov 2, 2024
1 parent 9f4f77e commit bf819af
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 443 deletions.
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 128 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Contributing to PolyglotCode

Thank you for considering contributing to **PolyglotCode**! Your support and collaboration are greatly appreciated.

## How to Contribute

1. **Fork the Repository**
- Click the "Fork" button on the top right of this repository's page to create your own copy of the project.
- Clone your forked repository to your local machine:
```bash
git clone https://github.com/mulla028/PolyglotCode.git
```
- Navigate into the project directory:
```bash
cd PolyglotCode
```

2. **Setting Up Your Environment**
- Ensure you have Java and Maven installed.
- Generate and provide your Cohere API key into the `defaultValue` of the `-a` and `--api-key` flags inside the main class:
```java
@Option(
names = {"-a", "--api-key"},
defaultValue = "YOUR_API-KEY",
description = "Modifying API key manually"
)
private String api;
```
- Alternatively, you can specify the API key when running the tool (see "Usage").

3. **Build and Test**
- Make the bash script executable:
```bash
chmod +x polyglot
```
- Compile the source code using Maven:
```bash
mvn package
```
- Run and test the tool to ensure everything works correctly.

4. **Create Your Contribution**
- Make changes or add new features in your local repository.
- Please write clear, concise, and well-documented code.
- Ensure that your code follows the style and conventions of the project.

5. **Commit Your Changes**
- Create a new branch for your feature or fix:
```bash
git checkout -b feature-name
```
- Commit your changes with a descriptive commit message:
```bash
git add .
git commit -m "Add a concise description of your change"
```

6. **Push to Your Fork**
- Push your branch to your forked repository:
```bash
git push origin feature-name
```

7. **Submit a Pull Request (PR)**
- Go to the original repository and create a pull request from your forked repository.
- Provide a clear description of the changes you've made and the problem it solves or feature it adds.
- Reference any related issues in the pull request description if applicable.
## Guidelines for Contributions
1. **Follow the Coding Standards**
- Use appropriate naming conventions and indentation.
- Ensure your code is clean and well-documented.
2. **Document Your Changes**
- Update the `README.md` file if your changes include new features or configurations.
- Include examples of how to use new features if applicable.
3. **Testing and Validation**
- Before submitting your PR, thoroughly test your code.
- Ensure that your contribution does not break existing functionality.
### Code Style and Linting
We use Checkstyle to ensure that our code adheres to a consistent style. Before submitting your pull request, please run Checkstyle to check for any code style violations.
#### Running Checkstyle
To run Checkstyle on the project, follow these steps:
1. **Ensure Checkstyle is Configured:**
Make sure the `checkstyle.xml` configuration file is in place. This file defines the rules for code style checks.
2. **Run Checkstyle:**
Open your terminal, navigate to the project directory, and execute the following command:
```bash
mvn checkstyle:check
```
3. **Review Output**
After running the Checkstyle check, review the output in the terminal for any errors or warnings and resolve them accordingly.
## Code Formatting
We use **Spotless** with Google Java Format to ensure consistent code style. Before submitting your changes, please format your code.
### How to Format Code
- Open your terminal and navigate to the project's root directory.
- Run the following command to format all source code:
```bash
mvn spotless:apply
```


## Reporting Issues

1. Use the [GitHub Issues](https://github.com/mulla028/PolyglotCode/issues) section to report bugs or suggest features.
2. When reporting a bug, provide as much detail as possible, including:
- Steps to reproduce the issue
- Your environment details (Java version, operating system, etc.)
- Any relevant error messages or logs

## Additional Notes

- **License**: By contributing, you agree that your contributions will be licensed under the [MIT License](https://opensource.org/licenses/MIT).
- **Community**: Be respectful and considerate of others. We value open communication and constructive feedback.

Happy coding, and thank you for contributing to **PolyglotCode**!
17 changes: 17 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<!-- Modules that analyze the entire source file -->
<module name="FileTabCharacter"/>

<!-- TreeWalker module should only include checks that work on the abstract syntax tree -->
<module name="TreeWalker">
<module name="WhitespaceAround"/>
<module name="EmptyLineSeparator"/>

<!-- Import checks -->
<!-- Add more TreeWalker-compatible checks as needed -->
</module>
</module>
45 changes: 43 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
Expand Down Expand Up @@ -74,6 +74,47 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.37.0</version> <!-- Check for the latest version on the Spotless GitHub page -->
<configuration>
<java>
<googleJavaFormat/>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>



</plugins>
</build>

Expand Down
Loading

0 comments on commit bf819af

Please sign in to comment.