Skip to content

refactor: simplify code#181

Merged
bc-m merged 31 commits intomainfrom
refactor/simplify-code
Mar 18, 2026
Merged

refactor: simplify code#181
bc-m merged 31 commits intomainfrom
refactor/simplify-code

Conversation

@bc-m
Copy link
Copy Markdown
Owner

@bc-m bc-m commented Mar 18, 2026

No description provided.

bc-m and others added 30 commits March 12, 2026 09:55
- Remove misleading Option wrapper from get_attributes (always returned Some)
- Replace match bool patterns with if/else
- Simplify Calculation::display with filter/cloned
- Consolidate duplicated skeleton push logic in xml_processor
- Replace match with let...else in catalog/xml_processor/utils
- Remove dead code and debug println statements
- Use &str instead of &String, unwrap_or_default, as_deref

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Change CatalogConfig fields to static references (avoid heap allocation)
- Simplify get_attribute to search directly instead of collecting into Vec
- Use LazyLock for regex compilation in write_text_file
- Replace verbose match patterns with if-let, let-else, matches!()
- Use map_or, and_then, unwrap_or_default for cleaner option handling
- Remove dead code in field_reference inner match
- Consolidate sequential guards in parameter_values
- Remove unused depth tracking in custom_function_sanitizer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove redundant .to_string() on already-owned String values
- Replace .clone().map() with .as_ref().map() to avoid unnecessary clones
- Eliminate double computation of text_element_to_string/cdata_to_string
- Remove dead Entity._clear() method and commented-out code
- Return &'static str from bool_to_string instead of allocating String
- Replace .as_str() with & coercion (idiomatic Rust)
- Use unwrap_or_default() instead of unwrap_or("".to_string())
- Simplify version_string_to_number with zip+sum iterator

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove dead _delete_then_create_dir function
- Remove remaining redundant .as_str() on String comparisons
- Use .into_owned() instead of .to_string() on Cow<str>
- Replace "".to_string() with String::new()
- Change &PathBuf params to &Path (clippy ptr_arg)
- Simplify match Ok/Err to map/unwrap_or_default in xml_utils
- Use unwrap_or_else to defer allocations
- Simplify VariableReference::display with as_ref().map()
- Use is_none_or for cleaner option comparison
- Replace fs::File::open+read_to_end with fs::read

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove dead comment in catalog.rs
- Fix import ordering to follow std -> external -> crate convention
- Simplify process_top_level_section by removing mutable boolean
- Extract shared path_stack check in rename_file_if_necessary

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… dead code

- Deduplicate identical attribute extraction for CustomFunction/CustomFunctionReference
- Remove no-op Script element branch in script_sanitizer
- Remove redundant indent_level assignment that gets overwritten

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…c Rust

- Pass u32 by value instead of reference (Copy type)
- Replace string comparisons with byte comparisons where possible
- Use into_owned() instead of to_string() for Cow values
- Remove redundant Vec<u8> type annotations (42 files)
- Use Default::default() for struct initialization
- Simplify utils: inline helpers, remove unused params, use str::lines()
- Deduplicate XML path extraction with shared closure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… patterns

- Remove duplicate rename_file_if_necessary and move_to_subfolder after test module
- Move extract_values_from_xml_paths before test module (clippy items_after_test_module)
- Simplify control flow and reduce verbosity across 40 files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Merge duplicate crate::utils import blocks in catalog.rs and xml_processor.rs
- Replace dead is_child variable with direct literal in catalog.rs
- Use let-else pattern for Option unwrapping in catalog.rs
- Reuse Boolean::on_off in BooleanContainer, fix unwrap() with safe comparison
- Remove unused anyhow::Result imports
- Use write_all instead of write! for plain string output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…trol flow

- Annotate `CatalogType` methods with `const fn` for compile-time evaluation
- Inline reusable `build_tree_path` to reduce code duplication in directory handling
- Use `ValueEnum` for derived `OutputTree` attributes
- Replace redundant format! calls with simpler string composition
- Migrate functions to use `Result<>` instead of custom error strings for consistency
- Optimize regex and string handling with capacity preallocation and in-place mutation
- Consolidate `saxml_version` checks into named constants and range comparison

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… usage

- Replace `Result` return types with direct types for XML parsers to streamline usage
- Deduplicate and simplify conditional branches in various script step handlers
- Use `Boolean::on_off` for boolean formatting across files
- Inline trivial string formatting and remove redundant `unwrap()` calls
- Replace ad-hoc list handling with reusable `Vec::join` strategies
…ze struct usage

- Replace `to_path_buf` with direct references for `root_out_dir` in `ProcessingContext`
- Deduplicate version checks with constant `VERSION_2_2_3_4`
- Consolidate skeleton depth checks into `should_add_to_skeleton` helper
- Simplify attribute extraction with inline `anyhow` error handling
- Use `mem::replace` for safer state updates in folder handling
… functions

- Replace custom XML file directory recursion with `for_each_xml_file` helper
- Simplify `process_cf_xml` and `process_script_xml` into shared closure
- Optimize directory validation with `ensure` for cleaner error handling
- Simplify `escape_filename` by removing redundant `trim` and allocations
- Refactor attribute extraction in `parse_cf_xml` for clarity and brevity
- Replace tuple-based folder attribute parsing with `FolderAttributes` struct for improved clarity
- Simplify folder handling by inlining logical checks and removing redundant conditions
- Refactor utility functions: unify `unescape_xml_entities` and `escape_xml_entities` naming
- Deduplicate `end_element_to_string_from_start_element` by reusing `format_end_tag`
- Switch to `bail!` macro for consistent error handling, removing verbosity
- Use `let-else` patterns and `.then()` idiom for Options to simplify control flow
- Replace match literals with direct function usage for brevity
- Remove unnecessary fields from structs in button handling logic
- Optimize String allocation by replacing redundant mutations with direct updates
…conditions

- Replace redundant subfolder path checks with concise `let-else` and `.then_some` idioms
- Inline and unify folder structure handling for catalogs with/without explicit tracking
- Improve readability and maintainability by restructuring `determine_subfolder_path`
…tputs

- Replace redundant conditional branches with `match` statement for clarity
- Consolidate `create_sanitized_scripts` and `create_sanitized_custom_functions` calls
- Simplify control flow for `CatalogType` variants, reducing code duplication
- Consolidate conditional branches into a single `match` statement
- Simplify attribute extraction logic for `CustomFunction` and `CustomFunctionReference`
- Remove redundant checks and improve readability
- Combine redundant branches in `match` for streamlined `start_tag` processing
- Simplify section and file name assignment logic with tuple unpacking
- Improve readability by reducing code duplication in context updates and processing
…g` and optimize string conversion

- Replace redundant decode calls with `let-else` for concise logic
- Simplify XML entity handling by consolidating paths for readability
- Adjust element-to-string conversions to avoid unnecessary `.as_str()` usage
…tting

- Simplify time formatting logic by consolidating conditions into a `match` statement
- Improve readability and reduce redundancy in elapsed time handling
…TTERNS` constant

- Extract redundant skip patterns into a shared `SKIP_PATTERNS` constant
- Simplify `should_skip_line` by using `.iter().any` for improved readability
- Replace redundant string allocations with direct `.to_string()` usage
- Consolidate `on_off` and second parameter formatting for improved clarity
- Add consistent usage of `buf.clear()` at the end of processing loops for improved hygiene
- Replace `match` branches with concise conditional expressions where applicable
- Simplify attribute parsing with direct `.parse()` calls and reduce redundant error handling
- Standardize element name handling and improve control flow readability
…g logic

- Consolidate conditional branching with concise expressions and reusable patterns
- Simplify logic in `sanitize.rs`, parameter handling, and XML inlining
- Improve readability and reduce redundant code across modules
- Introduce reusable modules for `skeleton`, `entity`, and `output_path` to improve separation of concerns
- Simplify `sanitize.rs` parameter formatting with `format_parameters` and refined processing flow
- Replace redundant context field assignments with a new `DocumentInfo` struct
- Consolidate version string handling with `version_string_to_number` providing reusable methods
- Enhance code readability by modularizing and consolidating redundant XML-related logic
@bc-m bc-m marked this pull request as ready for review March 18, 2026 22:14
@bc-m bc-m merged commit 795d9ce into main Mar 18, 2026
1 check passed
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.

1 participant