netbox-acls icon indicating copy to clipboard operation
netbox-acls copied to clipboard

Add model tests

Open ryanmerolle opened this issue 2 years ago β€’ 3 comments

Pull Request

Related Issue

Closes #47 Closes #133

New Behavior

  • Adds tests to models.
  • Addresses a bug found in the AccessList model discovered while adding tests.

Contrast to Current Behavior

No tests for models A bug does not allow hyphens in access-list names

Discussion: Benefits and Drawbacks

...

Changes to the Documentation

...

Proposed Release Note Entry

...

Double Check

  • [x] I have explained my PR according to the information in the comments or in a linked issue.
  • [x] My PR targets the dev branch.

ryanmerolle avatar Feb 02 '23 22:02 ryanmerolle

Sourcery Code Quality Report

βœ… Β Merging this PR will increase code quality in the affected files by 0.78%.

Quality metrics Before After Change
Complexity 11.01 πŸ™‚ 10.74 πŸ™‚ -0.27 πŸ‘
Method Length 106.73 πŸ™‚ 105.04 πŸ™‚ -1.69 πŸ‘
Working memory 8.86 πŸ™‚ 8.76 πŸ™‚ -0.10 πŸ‘
Quality 57.62% πŸ™‚ 58.40% πŸ™‚ 0.78% πŸ‘
Other metrics Before After Change
Lines 755 768 13
Changed files Quality Before Quality After Quality Change
netbox_acls/forms/models.py 48.09% 😞 48.09% 😞 0.00%
netbox_acls/graphql/schema.py 86.70% ⭐ 86.70% ⭐ 0.00%
netbox_acls/graphql/types.py 72.73% πŸ™‚ 72.73% πŸ™‚ 0.00%
netbox_acls/migrations/0002_alter_accesslist_options_and_more.py 61.79% πŸ™‚ 61.79% πŸ™‚ 0.00%
netbox_acls/migrations/0003_netbox_acls.py 75.10% ⭐ 75.10% ⭐ 0.00%
netbox_acls/models/access_lists.py 94.10% ⭐ 90.78% ⭐ -3.32% πŸ‘Ž

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
netbox_acls/forms/models.py ACLInterfaceAssignmentForm.clean 15 πŸ™‚ 282 β›” 15 😞 31.91% 😞 Try splitting into smaller methods. Extract out complex expressions
netbox_acls/forms/models.py AccessListForm.clean 21 😞 236 β›” 13 😞 32.23% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
netbox_acls/forms/models.py AccessListForm.__init__ 27 😞 194 😞 8 πŸ™‚ 40.82% 😞 Refactor to reduce nesting. Try splitting into smaller methods
netbox_acls/forms/models.py ACLExtendedRuleForm.clean 15 πŸ™‚ 121 😞 6 ⭐ 61.28% πŸ™‚ Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • πŸ™‚ good
  • 😞 poor
  • β›” very poor

The πŸ‘ and πŸ‘Ž indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

sourcery-ai[bot] avatar Feb 02 '23 22:02 sourcery-ai[bot]

@abhi1693 as discussed, I started pulling out the various fixes from my enormous branch.

This PR will focus on tests for models and any bugs in the model it may uncover.

ryanmerolle avatar Feb 02 '23 22:02 ryanmerolle

SonarCloud Quality Gate failed.Β  Β  Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 24 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Feb 07 '23 05:02 sonarqubecloud[bot]