Skip to content

32Butterfly/CleanCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

200 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Formatter

Project Description

Our team is developing command-line static code analysis tool that helps you to format your java code. It is a java program that allows users to format their code with less effort and time using the provided config however it can be configured to your liking based on rules mentioned below.

Tools and Technologies

Running the program

  • Download the built file from Formatter.
  • Extract the .zip file.
  • Enter the directory called Formatter of the extracted directory.
  • Execute cli command: (Java version should be the newest version or at least => 17.0.13).
  java -jar Formatter.jar

Formatting Features

Loops

  • For/While: Ensures spaces around operators, braces on the same line, and single-line body support.
    • For: Also supports formatting for for-each loops.
  • Do-While: Aligns do and { on the same line, and ensures proper spacing around the while keyword and condition.

Conditionals

  • If/Else: Standardizes placement of braces, spacing, and ladder structures.
    • Supports formatting of ternary operations for concise conditionals.
  • Switch: Formats cases, aligns default, and ensures indentation.

Variable Assignment

  • Ensures spaces around assignment = and arithmetic operators +, -, *, etc.

Whitespace

  • Cleans up inconsistent spaces, tabs, and empty lines.
  • Collapses multiple blank lines into one.

Configurations

  • Formatter has a configuration file that is located Formatter/config/formatter_config.cfg.
  • File can be edited either from the CLI or directly with a file editor editing the formatter_config.cfg file directly.

Allowed values for the configurations (these limits must be followed)

Option Values
indent_style tab/space
indent_size 0 < x < 10
open_brace_on_the_same_line true/false
space_before_control_paren true/false
space_around_operators true/false
space_before_comma true/false
space_after_comma true/false
newline_at_end_of_file true/false
blank_lines_after_imports 0 < x < 10

Additional information

For in-depth information about the formatting rules and configuration details, please refer to the docs/ directory. This includes detailed explanations on how the formatter works and how to configure it to suit your needs.

About

Static command-line tool for formatting and cleaning up Java code to keep it consistent and readable. Cloned from a private university repository used for a group project, so original issues and pull requests are not available.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages