Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

zap-api-scan.py: refactoring attempt#6410

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ioggstream wants to merge1 commit intozaproxy:main
base:main
Choose a base branch
Loading
fromioggstream:ioggstream-small-fixes

Conversation

@ioggstream
Copy link
Contributor

This PR

will be useful to discuss some refactoring proposal, including:

  • use%r or%s with logging instead of string concatenation for code readability;
  • use startswith with a tuple

have your say.

@ioggstreamioggstream changed the titleRefactoring attemptzap-api-scan.py: refactoring attemptJan 19, 2021
sys.exit(3)
ifformat!='openapi'andformat!='soap'andformat!='graphql':
logging.warning('Format must beeither\'openapi\',\'soap\', or\'graphql\'')
ifformatnotinSUPPORTED_FORMATS:
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

here and log levels can be validated by switching fromgetopt ->ArgumentParser. In python2, Argument parser was not in the PSL, while in python3 you have it already and you don't need to install it anymore.

port=get_free_port()

logging.debug('Using port:'+str(port))
logging.debug('Using port:%s',port)
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

the logger takes care callingstr orrepr depending on%s or%r

Choose a reason for hiding this comment

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

Any reason why not using f-string syntax ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I used to create strings only if logs are actually printed. Probably in this case it is ok using f-string.

f.write('# You can add your own messages to each rule by appending them after a tab on each line.\n')
forkey,ruleinsorted(all_dict.items()):
f.write(key+'\tWARN\t('+rule+')\n')
f.write(f'{key}\tWARN\t({rule})\n')
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

python 3.6 will be out of support from 2021-12. If we want to retain it, we can't use f-strings. Have your say.

@thc202
Copy link
Member

It might not worth doing major "cosmetic" refactors as per#6406 (comment) but if you still think worth doing to make other changes you plan easier, I'm all for it.

psiinon reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@k3v3nk3v3nk3v3n left review comments

@kalijalikalijalikalijali approved these changes

Reviewers whose approvals may not affect merge requirements

At least 2 approving reviews are required to merge this pull request.

Assignees

No one assigned

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ioggstream@thc202@k3v3n@kalijali

[8]ページ先頭

©2009-2025 Movatter.jp