Problem/Motivation

Several methods across the module had a cyclomatic complexity of 15 or higher, making them difficult to read, test in isolation, and maintain. Affected classes include Element/Name.php, NameFormatter, NameWidget, AutocompleteService, ElementValidatorService, GeneratorService, NameFormatParserService, AdditionalComponentService, and NameFormSettingsHelperTrait.

Steps to reproduce

Run a cyclomatic complexity analyser (e.g. PHPMetrics or a PHPStan complexity rule) against the 8.x-1.x branch. The methods listed above all report complexity of 15 or higher.

Proposed resolution

Each oversized method was decomposed into focused private or protected helpers using the "extract method" pattern. The original method in each case now reads as a short, high-level sequence of named steps. New and expanded Unit and Kernel test classes were added alongside every refactored class to cover the extracted paths directly.

Remaining tasks

User interface changes

None. Rendered output of the formatter, widget, and element is identical to 8.x-1.x.

API changes

Data model changes

Issue fork name-3590747

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bluegeek9 created an issue. See original summary.

bluegeek9’s picture

Title: Reduce complexity » Reduce complexity:methods
Issue summary: View changes
bluegeek9’s picture

Title: Reduce complexity:methods » Reduce complexity: methods

bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.