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

try to fix #1494 #1502

Merged
merged 7 commits into from
Jan 16, 2023
Merged

try to fix #1494 #1502

merged 7 commits into from
Jan 16, 2023

Conversation

lasconic
Copy link
Collaborator

@lasconic lasconic commented Jan 6, 2023

Fixes #1494

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 6, 2023

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 3.09 ⭐ 2.92 ⭐ -0.17 👍
Method Length 85.52 🙂 77.76 🙂 -7.76 👍
Working memory 7.60 🙂 7.38 🙂 -0.22 👍
Quality 69.55% 🙂 72.83% 🙂 3.28% 👍
Other metrics Before After Change
Lines 837 822 -15
Changed files Quality Before Quality After Quality Change
scripts/__main__.py 83.33% ⭐ 83.32% ⭐ -0.01% 👎
wikidict/utils.py 65.44% 🙂 69.19% 🙂 3.75% 👍
wikidict/lang/__init__.py 81.86% ⭐ 82.92% ⭐ 1.06% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
wikidict/utils.py transform 8 ⭐ 132 😞 10 😞 57.08% 🙂 Try splitting into smaller methods. Extract out complex expressions
wikidict/utils.py process_templates 9 🙂 157 😞 8 🙂 57.68% 🙂 Try splitting into smaller methods
wikidict/utils.py clean 3 ⭐ 127 😞 11 😞 60.64% 🙂 Try splitting into smaller methods. Extract out complex expressions
wikidict/utils.py table2html 6 ⭐ 80 🙂 11 😞 64.02% 🙂 Extract out complex expressions
wikidict/utils.py get_word_of_the_day 1 ⭐ 142 😞 9 🙂 64.85% 🙂 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!

scripts/all-namespaces.py Outdated Show resolved Hide resolved
wikidict/utils.py Outdated Show resolved Hide resolved
wikidict/utils.py Outdated Show resolved Hide resolved
wikidict/utils.py Outdated Show resolved Hide resolved
@BoboTiG
Copy link
Owner

BoboTiG commented Jan 6, 2023

good for review, it's done on my side.

# [[File:...|...]] -> ''
# except [[File:...|{{...}}]] that will end on '{{...}}'
pattern = "|".join(iter(namespaces[locale]))
text = sub(rf"\[\[(?:{pattern}):[^\{{]+?(?=\]\])\]\]*", "", text)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a ugly hack for "Annexe" and "Fichier". We want to keep namespaces using at least one template, like [[Annexe:blablabla|{{foo:|bar}}]] but bot simple calls like [[Fichier:blablabla|foo|bar]].

It's fragile. If you can find another way, I'm open :)

Copy link
Owner

@BoboTiG BoboTiG Jan 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I found another way.

If we decided to parse those wikicode, and filter out later.
We really need to keep namespaces that doesn't end with a filename: we could do that check. If it seems to end with a file extension, then filter out. Else, keep the wikicode.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add more examples to be sure about a strategy.

@BoboTiG
Copy link
Owner

BoboTiG commented Jan 16, 2023

Well, WDYT about merging that PR as-is? Let's see what breaks then, I'm not motivated to complexify more the code for that use case (not now at least).

@lasconic
Copy link
Collaborator Author

Sure, let's merge and see.

@BoboTiG BoboTiG merged commit f82a1d0 into BoboTiG:master Jan 16, 2023
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.

Smarter link-with-namespace filter
2 participants