Skip to content

Conversation

@alexgarzao
Copy link
Collaborator

Closes #90

This PR refactors the operations logic in the analyzer module to improve maintainability and extensibility. The core change is moving the definition and handling of validation operations into a dedicated operations package, replacing the previous static map with a more structured and encapsulated approach. This update also introduces new helper methods and corresponding tests for operation validation.

Refactoring and modularization of operations logic:

  • Moved the operations definitions from internal/analyzer/operations.go to a new operations package, splitting the logic into operations.go (core logic and helpers) and operations_list.go (operation definitions). The old file was deleted and replaced with the new structure. [1] [2] [3]
  • Updated all usages in internal/analyzer/analyzer.go and internal/analyzer/parser_validation.go to use the new operations package and its helper methods, improving encapsulation and code clarity. [1] [2] [3] [4] [5] [6]

Testing improvements:

  • Added a new unit test file operations_test.go in the operations package to comprehensively test the validity of operations and their compatibility with field types.
  • Removed the legacy analyzer operation tests that were tightly coupled to the previous implementation.

These changes make it easier to extend and maintain operation validation logic, and ensure correctness with improved test coverage.

@alexgarzao alexgarzao self-assigned this Oct 11, 2025
@alexgarzao alexgarzao requested a review from Copilot October 11, 2025 18:43
Copy link
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 operations logic in the analyzer module to improve maintainability and extensibility. The core change is moving the definition and handling of validation operations into a dedicated operations package, replacing the previous static map with a more structured and encapsulated approach.

Key changes:

  • Moved operations definitions from internal/analyzer/operations.go to a new operations package with separate files for core logic and operation definitions
  • Updated all usages to use the new operations package with helper methods for better encapsulation
  • Changed the required validation condition from >= 1 to != 0 for map types to improve consistency

Reviewed Changes

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

Show a summary per file
File Description
internal/analyzer/operations.go Deleted - operations logic moved to new package
internal/analyzer/operations/operations.go New file with operations struct and helper methods
internal/analyzer/operations/operations_list.go New file with operation definitions
internal/analyzer/operations/operations_test.go New comprehensive test file for operations validation
internal/analyzer/analyzer.go Updated to use new operations package methods
internal/analyzer/parser_validation.go Updated to use new operations package and common types
internal/common/types.go Moved CountValues enum to common package
internal/common/field_type.go New file with FieldType struct moved from types.go
internal/codegenerator/condition_table.go Restructured condition definitions and improved logic
internal/codegenerator/test_elements.go Updated to use new operations package
tests/endtoend/validator__.go Updated generated validation code with improved conditions

@alexgarzao alexgarzao merged commit 36dca14 into main Oct 13, 2025
4 checks passed
@alexgarzao alexgarzao deleted the 90-refactor-tables-check-generate-code branch October 13, 2025 15:48
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.

Refactor in tables used to verify and generate code

3 participants