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

Test for IOTDB-1818 (Sourcery refactored) #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Oct 11, 2021

Pull Request #27 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/SteveYurongSu/iotdb pull/27/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

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

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from SteveYurongSu October 11, 2021 08:58
Comment on lines -741 to +743
for i in range(1, len(timestamps)):
if timestamps[i] < timestamps[i - 1]:
return False
return True
return all(
timestamps[i] >= timestamps[i - 1] for i in range(1, len(timestamps))
)
Copy link
Author

Choose a reason for hiding this comment

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

Function Session.check_sorted refactored with the following changes:

for i in range (size // 8 + 1):
for _ in range (size // 8 + 1):
Copy link
Author

Choose a reason for hiding this comment

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

Function BitMap.__init__ refactored with the following changes:

Comment on lines -65 to +67
for i in range(1, len(timestamps)):
if timestamps[i] < timestamps[i - 1]:
return False
return True
return all(
timestamps[i] >= timestamps[i - 1] for i in range(1, len(timestamps))
)
Copy link
Author

Choose a reason for hiding this comment

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

Function Tablet.check_sorted refactored with the following changes:

Comment on lines -83 to +92
if not self.__use_new:
format_str_list = [">"]
values_tobe_packed = []
for timestamp in self.__timestamps:
format_str_list.append("q")
values_tobe_packed.append(timestamp)

format_str = "".join(format_str_list)
return struct.pack(format_str, *values_tobe_packed)
else:
if self.__use_new:
return self.__timestamps.tobytes()

format_str_list = [">"]
values_tobe_packed = []
for timestamp in self.__timestamps:
format_str_list.append("q")
values_tobe_packed.append(timestamp)

format_str = "".join(format_str_list)
return struct.pack(format_str, *values_tobe_packed)
Copy link
Author

Choose a reason for hiding this comment

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

Function Tablet.get_binary_timestamps refactored with the following changes:

Comment on lines +160 to +171
format_str_list.append("i")
if self.__values[j][i] is not None:
value_bytes = bytes(self.__values[j][i], "utf-8")
format_str_list.append("i")
format_str_list.append(str(len(value_bytes)))
format_str_list.append("s")
values_tobe_packed.append(len(value_bytes))
values_tobe_packed.append(value_bytes)
else:
value_bytes = bytes("", "utf-8")
format_str_list.append("i")
format_str_list.append(str(len(value_bytes)))
format_str_list.append("s")
values_tobe_packed.append(len(value_bytes))
values_tobe_packed.append(value_bytes)
self.__mark_none_value(bitmaps, bitmap, i, j)
has_none = True

format_str_list.append(str(len(value_bytes)))
values_tobe_packed.append(len(value_bytes))
values_tobe_packed.append(value_bytes)
format_str_list.append("s")
Copy link
Author

Choose a reason for hiding this comment

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

Function Tablet.get_binary_values refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Oct 11, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 26.13 😞 25.51 😞 -0.62 👍
Method Length 60.78 ⭐ 60.08 ⭐ -0.70 👍
Working memory 11.19 😞 11.12 😞 -0.07 👍
Quality 57.56% 🙂 57.95% 🙂 0.39% 👍
Other metrics Before After Change
Lines 900 893 -7
Changed files Quality Before Quality After Quality Change
client-py/iotdb/Session.py 73.30% 🙂 73.13% 🙂 -0.17% 👎
client-py/iotdb/utils/BitMap.py 90.75% ⭐ 92.62% ⭐ 1.87% 👍
client-py/iotdb/utils/Tablet.py 25.57% 😞 25.52% 😞 -0.05% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
client-py/iotdb/utils/Tablet.py Tablet.get_binary_values 100 ⛔ 651 ⛔ 21 ⛔ 3.82% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
client-py/iotdb/Session.py Session.value_to_bytes 9 🙂 256 ⛔ 13 😞 40.99% 😞 Try splitting into smaller methods. Extract out complex expressions
client-py/iotdb/Session.py Session.open 12 🙂 170 😞 9 🙂 51.48% 🙂 Try splitting into smaller methods
client-py/iotdb/utils/Tablet.py Tablet.__init__ 4 ⭐ 96 🙂 14 😞 58.96% 🙂 Extract out complex expressions
client-py/iotdb/Session.py Session.gen_insert_records_req 6 ⭐ 97 🙂 11 😞 61.58% 🙂 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!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.

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