Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bomMd Function by Removing Unnecessary True Flag #77

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

teogor
Copy link
Owner

@teogor teogor commented Apr 17, 2024

Refactor bomMd Function to Remove Redundant Flag (Issue #76)

This pull request addresses a redundant flag identified in the bomMd function.

Issue:

The current implementation of bomMd includes a conditional statement that checks for a boolean flag true regardless of its value. This always writes default content to the file, rendering the flag unnecessary.

Proposed Change:

  • The redundant flag true has been removed from the conditional statement.
  • The simplified code now checks only for the existence of the file (!file.exists()).
  • Default content is written only when the file is missing.

Benefits:

  • Improves code clarity and removes unnecessary complexity.
  • Ensures default content is written only under the intended condition (missing file).

Potential Impact:

Removing the flag shouldn't introduce any functional changes. However, if there was a specific reason for the current behavior (documented nowhere), this change might have unintended consequences.

Additional Notes:

If there's a documented reason for the previous behavior, please consider adding a comment within the code explaining the rationale behind the simplification.

By addressing this redundancy, we maintain a cleaner and more efficient implementation of the bomMd function.

Code Snippet (After Change):

fun bomMd(
  inputDir: File,
  bomModule: ModuleDescriptor,
  modules: List<ModuleDescriptor>,
  includeOwner: Boolean,
  asModule: Boolean,
) {
  val file = File(inputDir, "index.md").also { file ->
    if (!file.exists()) {
      file.writeText(
        buildString {
          append(bomMdDefault)
        },
      )
    }
  }
}

Closes #76

@teogor teogor added this to the 1.0.1 milestone Apr 17, 2024
@teogor teogor self-assigned this Apr 17, 2024
@teogor teogor merged commit c8ed3b4 into main Apr 17, 2024
5 checks passed
@teogor teogor deleted the issue-#76/redundant-flag branch April 17, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[Bug]: Remove Unnecessary true Flag in bomMd Function
1 participant