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

Refactor configuration- and comment-related logic #57

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

darrenwee
Copy link

I migrated comment.py to a more object-oriented approach. This doesn't add any new features, but it makes it easier to maintain and make changes to the bot. This also grants developers the lovely support of autocomplete and type hints for easier development.

This paves the way for migrating the split-long-comment-into-two-comments logic below into a nicer abstraction so that concerns are properly separated and you don't have to limit the bot to exactly two comments.

sneakpeek/scan.py

Lines 70 to 83 in 5e25bae

try:
logging.info("Attempting to post two comments")
i=1
while (comment_markdown[config.COMMENT_LENGTH_LIMIT-i] != " "):
i += 1
part_1 = comment_markdown[0: config.COMMENT_LENGTH_LIMIT-i]
part_2 = comment_markdown[config.COMMENT_LENGTH_LIMIT-i:]
if (part_2[0] != ">"):
part_2 = ">" + part_2
first_comment = submission.reply(part_1)
first_comment.reply(part_2)
logging.info("Comments posting succeeded")

I also modified some parts of config.py. The version and repo link is now put inside about.yaml so that no source code changes are required to bump the version - this makes the git history cleaner for code. It also removes the magic strings from other classes/files.

Since I did this, I decided to also create a unified interface to access all bot configuration parameters, the BotConfig, which you can inject wherever needed.

@darrenwee
Copy link
Author

Would you mind pasting what Prospector_F999's lint rule is? Codacy is broken for me 😞

@fterh
Copy link
Owner

fterh commented Dec 27, 2019

Hey sorry, for some reason I don't receive email notifications for pull requests so I didn't realize you created this >1 month ago.

TBH I'm not too sure about Codacy too. It's my first time using it ><

@darrenwee
Copy link
Author

No worries! Your call on whether to ignore Codacy or not. It seems pretty buggy, and Prospector F999 seems to be non-specific by design so I have no idea what the issue is. https://github.com/PyCQA/prospector/blob/f431c838cc86b84d68b5f0350ae9113257995262/prospector/tools/pyflakes/__init__.py

Will you be willing to merge?

@fterh
Copy link
Owner

fterh commented Jan 2, 2020

Hi, sorry for the late reply. Just an update that I'm still looking through your code changes and I'll follow up with a more conclusive reply soon :)

(It's my holiday break now so I'm taking things really chill haha)

comment.py Show resolved Hide resolved
handlers/abstract_base_handler.py Show resolved Hide resolved
config.py Show resolved Hide resolved
@fterh
Copy link
Owner

fterh commented Jan 16, 2020

@darrenwee hey you still there? I've left a review with comments :)

@fterh
Copy link
Owner

fterh commented Jan 25, 2020

@darrenwee Alright, looks good. Make a PR into the develop branch instead and I'll merge it in. Sorry for the late response, am working on another project.

@darrenwee darrenwee changed the base branch from master to develop February 15, 2020 04:08
@darrenwee
Copy link
Author

@fterh there you go! I think you can edit PRs as the owner of the repo so you can make these changes on your own next time! (edit button next to the title)

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