Skip to content

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Mar 6, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from srobledog March 6, 2023 15:00
if self.doi:
return self.doi
return self._label()
return self.doi or self._label()
Copy link
Author

Choose a reason for hiding this comment

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

Function Article.label refactored with the following changes:

Comment on lines -79 to +87
if not self.doi:
return {self.label, self._label(lower_p=True)}
return {
self.doi,
self.label,
self._label(exclude_doi=True),
self._label(lower_p=True),
self._label(exclude_doi=True, lower_p=True),
}
return (
{
self.doi,
self.label,
self._label(exclude_doi=True),
self._label(lower_p=True),
self._label(exclude_doi=True, lower_p=True),
}
if self.doi
else {self.label, self._label(lower_p=True)}
)
Copy link
Author

Choose a reason for hiding this comment

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

Function Article.labels refactored with the following changes:

Comment on lines -94 to -100
{
{}
if simplified
else {
"references": self.references,
"extra": self.extra,
"sources": list(self.sources),
}
if not simplified
else {}
Copy link
Author

Choose a reason for hiding this comment

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

Function Article.to_dict refactored with the following changes:

format or dumps them in the `output`.
"""
if not len(sources) > 0:
if len(sources) <= 0:
Copy link
Author

Choose a reason for hiding this comment

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

Function citation_pairs refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

format or dumps them in the `output`.
"""
if not len(sources) > 0:
if len(sources) <= 0:
Copy link
Author

Choose a reason for hiding this comment

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

Function to_json refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

raw_dict.setdefault("CR", [])
for key, seq in raw_dict.items():
processed_data.update(parse(key, seq))
processed_data |= parse(key, seq)
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_all refactored with the following changes:

if not raw:
return None
return " ".join(raw)
return " ".join(raw) if raw else None
Copy link
Author

Choose a reason for hiding this comment

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

Function _joined refactored with the following changes:

Comment on lines -54 to +52
data.update(page.groupdict())
data |= page.groupdict()
Copy link
Author

Choose a reason for hiding this comment

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

Function _find_volume_info refactored with the following changes:

else None,
"journal": None
if journal.isspace()
else journal.strip().replace(".", "").upper(),
Copy link
Author

Choose a reason for hiding this comment

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

Function _scopus_ref_to_isi refactored with the following changes:

Comment on lines -159 to +157
article = parse_record(item.strip())
yield article
yield parse_record(item.strip())
Copy link
Author

Choose a reason for hiding this comment

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

Function parse_file refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Mar 6, 2023

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.70%.

Quality metrics Before After Change
Complexity 5.23 ⭐ 5.37 ⭐ 0.14 👎
Method Length 85.75 🙂 85.09 🙂 -0.66 👍
Working memory 6.84 🙂 6.98 🙂 0.14 👎
Quality 72.63% 🙂 71.93% 🙂 -0.70% 👎
Other metrics Before After Change
Lines 598 595 -3
Changed files Quality Before Quality After Quality Change
wostools/article.py 68.44% 🙂 66.58% 🙂 -1.86% 👎
wostools/cli.py 74.08% 🙂 74.18% 🙂 0.10% 👍
wostools/fields.py 86.50% ⭐ 86.60% ⭐ 0.10% 👍
wostools/sources/scopus.py 70.78% 🙂 70.11% 🙂 -0.67% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
wostools/sources/scopus.py ris_to_dict 15 🙂 131 😞 9 🙂 53.04% 🙂 Try splitting into smaller methods
wostools/sources/scopus.py _find_volume_info 14 🙂 151 😞 7 🙂 56.20% 🙂 Try splitting into smaller methods
wostools/article.py Article.__init__ 4 ⭐ 108 🙂 14 😞 57.33% 🙂 Extract out complex expressions
wostools/article.py Article.from_isi_text 7 ⭐ 168 😞 8 🙂 58.49% 🙂 Try splitting into smaller methods
wostools/sources/scopus.py _scopus_ref_to_isi 1 ⭐ 134 😞 11 😞 61.80% 🙂 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!

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.

0 participants