Skip to content

refactor: Uniform init defaults - PLUTO-1426#127

Merged
franciscoovazevedo merged 2 commits intomainfrom
uniformize-init-defaults
May 27, 2025
Merged

refactor: Uniform init defaults - PLUTO-1426#127
franciscoovazevedo merged 2 commits intomainfrom
uniformize-init-defaults

Conversation

@franciscoovazevedo
Copy link
Copy Markdown
Contributor

No description provided.

@franciscoovazevedo franciscoovazevedo changed the base branch from main to refactor-client-package May 20, 2025 15:38
@franciscoovazevedo franciscoovazevedo force-pushed the uniformize-init-defaults branch from 48a6adc to 2ac9773 Compare May 20, 2025 15:52
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 20, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.79% 54.81%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c7a56ea) 4585 1411 30.77%
Head commit (bab1ed5) 4531 (-54) 1430 (+19) 31.56% (+0.79%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#127) 104 57 54.81%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@franciscoovazevedo franciscoovazevedo changed the title WIP- refactor: Uniformize init defaults refactor: Uniformize init defaults May 26, 2025
@franciscoovazevedo franciscoovazevedo marked this pull request as ready for review May 26, 2025 09:14
@franciscoovazevedo franciscoovazevedo force-pushed the uniformize-init-defaults branch from 86fcf5b to de355cd Compare May 26, 2025 09:59
@franciscoovazevedo franciscoovazevedo changed the base branch from refactor-client-package to main May 26, 2025 10:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the configuration file creation logic for several tools to uniformly use provided defaults and simplify file writing. Key changes include updating the function signatures for ESLint and Lizard configuration creation to write files directly, adding helper functions for parameter handling, and streamlining config file creation in the init command.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tools/lizard/lizardConfigCreator.go Updates CreateLizardConfig to accept a toolsConfigDir and write the config directly.
tools/eslintConfigCreator_test.go Revises tests to use temporary directories and read back the generated ESLint config.
tools/eslintConfigCreator.go Refactors ESLint config creation to use a new helper (removePlugins) and write file using a common helper.
cmd/init.go Adjusts calls to config creation functions for ESLint and Lizard to accommodate their new signatures.
Comments suppressed due to low confidence (2)

tools/eslintConfigCreator.go:115

  • The new removePlugins function now skips any rule that contains an underscore based solely on its plugin check, whereas the previous implementation checked for plugin rules using '/'. Please ensure this change in behavior is intended and covers all required cases.
rule, skipRule := removePlugins(rule)

cmd/init.go:418

  • The removal of the branch that retrieves default Lizard configuration when patternConfiguration is empty may lead to an empty configuration file. Confirm that this change is intended under the new uniform default behavior.
patterns := make([]domain.PatternDefinition, len(patternConfiguration))

@zhamborova zhamborova changed the title refactor: Uniformize init defaults refactor: Uniform init defaults May 26, 2025
Copy link
Copy Markdown
Contributor

@zhamborova zhamborova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread cmd/init.go
return fmt.Errorf("failed to create default ESLint config: %v", err)
}
fmt.Println("Default ESLint configuration created")
err := tools.CreateEslintConfig(toolsConfigDir, patternConfiguration)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: we could also refactor this function: we could abstract the error handling and logging, wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can and should, but I think we should do it for all tools and not just eslint, in the same PR

@franciscoovazevedo franciscoovazevedo changed the title refactor: Uniform init defaults refactor: Uniform init defaults - PLUTO-1424 May 26, 2025
@franciscoovazevedo franciscoovazevedo force-pushed the uniformize-init-defaults branch from de355cd to bab1ed5 Compare May 26, 2025 11:27
@franciscoovazevedo franciscoovazevedo changed the title refactor: Uniform init defaults - PLUTO-1424 refactor: Uniform init defaults - PLUTO-1426 May 26, 2025
@franciscoovazevedo franciscoovazevedo merged commit cb2527b into main May 27, 2025
10 checks passed
@alerizzo alerizzo deleted the uniformize-init-defaults branch June 3, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants