Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reference naming #624

Merged
merged 3 commits into from Aug 22, 2022
Merged

Conversation

tvt173
Copy link
Collaborator

@tvt173 tvt173 commented Aug 22, 2022

Hi @joamatab , this PR makes reference naming more reliable, by replacing the alias and aliases attributes with a property called name on ComponentReference and corresponding property named_references on Component. Because named_references is a calculated property, it is guaranteed to always stay in sync with Component.references. Because name and owner are both changed to properties, we also guard against strange cases where either are changed midway through creating a component.

I know the deprecation of alias/aliases may be controversial, but for now they should be smoothly deprecated with a DeprecationWarning. There should be no breaking changes, except the user is no longer allowed to explicitly set Component.aliases (which they never should have done anyways)

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 22, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.91%.

Quality metrics Before After Change
Complexity 7.84 ⭐ 7.42 ⭐ -0.42 👍
Method Length 67.64 🙂 64.65 🙂 -2.99 👍
Working memory 7.06 🙂 7.60 🙂 0.54 👎
Quality 64.58% 🙂 65.49% 🙂 0.91% 👍
Other metrics Before After Change
Lines 2770 2795 25
Changed files Quality Before Quality After Quality Change
gdsfactory/cell.py 47.64% 😞 48.79% 😞 1.15% 👍
gdsfactory/component.py 69.49% 🙂 69.80% 🙂 0.31% 👍
gdsfactory/component_reference.py 69.22% 🙂 70.29% 🙂 1.07% 👍
gdsfactory/copy.py 49.43% 😞 50.54% 🙂 1.11% 👍
gdsfactory/get_netlist.py 66.04% 🙂 67.56% 🙂 1.52% 👍
gdsfactory/components/component_sequence.py 49.36% 😞 50.24% 🙂 0.88% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
gdsfactory/cell.py cell_without_validator 48 ⛔ 633 ⛔ 5.51% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
gdsfactory/component.py Component.write_gds 14 🙂 286 ⛔ 16 ⛔ 31.47% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/components/component_sequence.py component_sequence 15 🙂 321 ⛔ 14 😞 31.90% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/component_reference.py ComponentReference.move 15 🙂 280 ⛔ 15 😞 31.99% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/component.py Component.remove_layers 22 😞 222 ⛔ 11 😞 35.70% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

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!

@sonarcloud
Copy link

sonarcloud bot commented Aug 22, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
2.0% 2.0% Duplication

@joamatab joamatab merged commit 391c48a into gdsfactory:master Aug 22, 2022
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.

None yet

2 participants