Skip to content

refactoring: evaluate RuleElements with @sindresorhus/ow/isValid #97

@gregswindle

Description

@gregswindle

code Refactoring proposal

1. Design summary / code smell(s)

Version 1.2.0 of archetypes-rules has:

  • 19 production dependencies
  • 62 development dependencies

2. Refactoring proposal(s)

  1. Simplify RuleContext evaluations with @sindresorhus/ow/isValid function.

  2. Rename the module @archetypes/rules.

  3. Extend all @archetypes/rules/Variables with @sindresorhus/ow methods (by ECMAScript data type).

3. Code quality improvement scores Sonar Quality Gate

  • The refactorings changes have either:

    • Reduced complexity, duplications, issues, security issues;
    • Improved maintainability or reliability; or
    • Both.

3.1. Complexity measures

These measures indicate how simple—or complicated—the control flow of the application is.
Cyclomatic Complexity
Measures the minimum number of test cases (i.e., conditional branches) are required for full test coverage.
Cognitive Complexity
Measures how difficult the application is to understand.
Version Cyclomatic Complexity Cognitive Complexity
v1.2.0 210 48
👎 v2.0.0 225 52

3.2. Source Lines Of Code (SLOC)

Version SLOC
v1.2.0 1,265
👎 v2.0.0 1,391

3.3. Dependencies (production)

Version Dependency count
v1.2.0 19
👍 v2.0.0 15

3.4. Bundle size (gzip)

Version Packed size Unpacked Size
v1.2.0 16.1 kB 68.9 kB
👎 v2.0.0 16.6 kB 71.2 kB

3.5. Code quality results summary

Measure Scores
Quality gate Sonar Alert Status Metrics
Defects (Bugs) Sonar Bugs Metrics
Duplications Sonar Duplicated Lines Density Metrics
Maintainability Sonar Code Smells Metrics
Sonar Sqale Rating Metrics
Sonar Sqale Index Metrics
Sonar Ncloc Metrics
Reliability Sonar Reliability Rating Metrics
Security Sonar Security Rating Metrics
Sonar Vulnerabilities Metrics
Test coverage Sonar Coverage Metrics

Metadata

Metadata

Assignees

Labels

priority: mediumWill add consumer value when released.type: breaking changeModifications affect or replace the public API. ⇧ Bumps the MAJOR semver.type: buildChanges to product build.type: refactorRestructuring source code without changing its external behavior.type: testAdding, correcting, or improving tests (coverage).

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions