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

⚡ update cex_exchange_plugin.py and dex_exchange_plugin.py #1434

Merged
merged 3 commits into from
Apr 8, 2024
Merged

Conversation

mraniki
Copy link
Owner

@mraniki mraniki commented Apr 8, 2024

No description provided.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @mraniki - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +55 to +61
if settings.bot_ignore not in msg or settings.bot_prefix not in msg:
if await self.fmo.search(msg) and self.should_handle_timeframe():
order = await self.fmo.get_order(msg)
if order and settings.trading_enabled:
trade = await self.exchange.submit_order(order)
if trade:
await send_notification(trade)
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Merge nested if conditions (merge-nested-ifs)

Suggested change
if settings.bot_ignore not in msg or settings.bot_prefix not in msg:
if await self.fmo.search(msg) and self.should_handle_timeframe():
order = await self.fmo.get_order(msg)
if order and settings.trading_enabled:
trade = await self.exchange.submit_order(order)
if trade:
await send_notification(trade)
if (settings.bot_ignore not in msg or settings.bot_prefix not in msg) and (await self.fmo.search(msg) and self.should_handle_timeframe()):
order = await self.fmo.get_order(msg)
if order and settings.trading_enabled:
trade = await self.exchange.submit_order(order)
if trade:
await send_notification(trade)


ExplanationToo much nesting can make code difficult to understand, and this is especially
true in Python, where there are no brackets to help out with the delineation of
different nesting levels.

Reading deeply nested code is confusing, since you have to keep track of which
conditions relate to which levels. We therefore strive to reduce nesting where
possible, and the situation where two if conditions can be combined using
and is an easy win.

Comment on lines +48 to +54
if settings.bot_ignore not in msg or settings.bot_prefix not in msg:
if await self.fmo.search(msg) and self.should_handle_timeframe():
order = await self.fmo.get_order(msg)
if order and settings.trading_enabled:
trade = await self.exchange.submit_order(order)
if trade:
await send_notification(trade)
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Merge nested if conditions (merge-nested-ifs)

Suggested change
if settings.bot_ignore not in msg or settings.bot_prefix not in msg:
if await self.fmo.search(msg) and self.should_handle_timeframe():
order = await self.fmo.get_order(msg)
if order and settings.trading_enabled:
trade = await self.exchange.submit_order(order)
if trade:
await send_notification(trade)
if (settings.bot_ignore not in msg or settings.bot_prefix not in msg) and (await self.fmo.search(msg) and self.should_handle_timeframe()):
order = await self.fmo.get_order(msg)
if order and settings.trading_enabled:
trade = await self.exchange.submit_order(order)
if trade:
await send_notification(trade)


ExplanationToo much nesting can make code difficult to understand, and this is especially
true in Python, where there are no brackets to help out with the delineation of
different nesting levels.

Reading deeply nested code is confusing, since you have to keep track of which
conditions relate to which levels. We therefore strive to reduce nesting where
possible, and the situation where two if conditions can be combined using
and is an easy win.

@mraniki mraniki merged commit 10702c9 into main Apr 8, 2024
12 checks passed
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.

1 participant