moonbitlang / moon

The build system and package manager for MoonBit
https://moonbitlang.github.io/moon/
GNU Affero General Public License v3.0
187 stars 17 forks source link

Enable block style by default #478

Closed lijunchen closed 4 days ago

lijunchen commented 4 days ago

cc @Yoorkin

moon fmt                      => moon fmt --block-style=true
moon fmt --block-style        => moon fmt --block-style=true
moon fmt --block-style=true   => moon fmt --block-style=true
moon fmt --block-style=false  => moon fmt --block-style=false
peter-jerry-ye-code-review[bot] commented 4 days ago

From the provided git diff output, here are three observations and suggestions for potential issues or improvements:

  1. Enum Value Naming Consistency:

    • In the MoonBit test cases (test_moon_fmt and others), the enum values are sometimes written with inconsistent indentation and line breaks. For example:
      pub fn hello() -> String {
      "Hello, world!"
      }

      vs.

      pub fn hello() -> String {
      "Hello, world!"
      }

      Suggestion: Ensure consistent formatting, such as always using a single line for simple functions or consistently applying the same indentation style.

  2. Default Value Handling:

    • In crates/moon/src/cli/fmt.rs, the handling of the block_style option has changed to allow for an optional BlockStyle value. The code now uses unwrap_or_default() to handle the None case:
      block_style: cmd.block_style.unwrap_or_default(),

      Suggestion: Ensure that the default() method for BlockStyle returns the appropriate default value (BlockStyle::True or BlockStyle::False). This change ensures that the default behavior is explicitly defined and consistent.

  3. Documentation Update:

    • The documentation for the fmt command in docs/manual-zh/src/commands.md and docs/manual/src/commands.md has been updated to reflect the new block_style option with possible values false and true.

      * `--block-style <BLOCK_STYLE>` — Add separator between each segments
      
      Possible values: `false`, `true`

      Suggestion: Verify that the documentation accurately reflects the new behavior and that all relevant parts of the documentation are updated to match this change.

These suggestions aim to improve code readability, consistency, and ensure that the documentation accurately represents the functionality of the block_style option.