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

configurable terms for todo-in-comment #674

Merged
merged 17 commits into from Aug 29, 2022
Merged

Conversation

rikerfi
Copy link
Contributor

@rikerfi rikerfi commented Aug 4, 2022

It would be good if todo-in-comment rule has configurable terms.

E.g. robocop --configure todo-in-comment:todos:OMG,bug also this work robocop --configure "todo-in-comment:todos:remove me,fix this ugly bug" This should enable also terms in local language.

Work in progress: documentation, tests

What would be the best location to place rule configuration tests?

@bhirsz
Copy link
Member

bhirsz commented Aug 4, 2022

Like you probably noticed our 'test framework' auto generates test for all rules with default configs. To test rule with custom config we can use following file:

https://github.com/MarketSquare/robotframework-robocop/blob/master/tests/atest/custom_tests.yaml

Either add entry with name of the rule / or update if the rule is already there with your desired config and path to test data files.

For example:

  inconsistent-assignment:
    - config: inconsistent-assignment:assignment_sign_type:space_and_equal_sign
      src_dir: misc/inconsistent-assignment-const
    - config: inconsistent-assignment:assignment_sign_type:autodetect
      src_dir: misc/inconsistent-assignment-autodetect

Runs two separate tests for rule inconsistent-assignment with different config and test data directories.

This:

  not-allowed-char-in-filename:
    - config: not-allowed-char-in-filename:pattern:\.(?!bar)
      src_dir: naming/not-allowed-char-in-filename-configured

is equivalent of running (in the tests/atest directory):

robocop --include not-allowed-char-in-filename --configure  not-allowed-char-in-filename:pattern:\.(?!bar) naming/not-allowed-char-in-filename-configured

Config can be single string (if you're only configuring one param) or list of strings (after #672 will be merged). But I think you don't need to configure more than one param per test so you don't need to wait for 672 and just use string for configuration.

@bhirsz
Copy link
Member

bhirsz commented Aug 4, 2022

I actually put this information in our CONTRIBUTING docs but it's less detailed here, maybe I should update it soon ;) This can get confusing - our test framework is useful for our needs but even I (author) tend to forgot how it works with autogeneration/custom tests.

Edit - I did not put this information in contributing docs. Uh!

robocop/checkers/comments.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2022

Codecov Report

Merging #674 (9fef356) into master (41943b0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #674   +/-   ##
=======================================
  Coverage   97.40%   97.40%           
=======================================
  Files          23       23           
  Lines        2886     2893    +7     
=======================================
+ Hits         2811     2818    +7     
  Misses         75       75           
Impacted Files Coverage Δ
robocop/checkers/comments.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

robocop/checkers/comments.py Outdated Show resolved Hide resolved
@rikerfi rikerfi force-pushed the master branch 3 times, most recently from e9462a5 to 1d00d9d Compare August 5, 2022 09:35
@rikerfi
Copy link
Contributor Author

rikerfi commented Aug 5, 2022

Something hassle with WIN environment. I try to fix that by guessing the problem is with Unicode characters. Unfortunately, I don't have WIN device available anytime soon. I need to postpone the PR a few days to find one 😓

@bhirsz
Copy link
Member

bhirsz commented Aug 5, 2022

Something hassle with WIN environment. I try to fix that by guessing the problem is with Unicode characters. Unfortunately, I don't have WIN device available anytime soon. I need to postpone the PR a few days to find one 😓

I can try to run in - I will let you know. From the results I also see it's running some of the tests that should be disabled by default (like benchmark test). It's most likely because of the 'tox -> nox' migration that happened recently. I will fix that one too

@bhirsz
Copy link
Member

bhirsz commented Aug 5, 2022

Something hassle with WIN environment. I try to fix that by guessing the problem is with Unicode characters. Unfortunately, I don't have WIN device available anytime soon. I need to postpone the PR a few days to find one 😓

I can try to run in - I will let you know. From the results I also see it's running some of the tests that should be disabled by default (like benchmark test). It's most likely because of the 'tox -> nox' migration that happened recently. I will fix that one too

There is problem with encoding, but it's not connected to your PR. All values passed to arguments/options are affected by it. I need to think about solution - it's not easy mix of argparse & encoding for specific platform

@bhirsz
Copy link
Member

bhirsz commented Aug 5, 2022

Something hassle with WIN environment. I try to fix that by guessing the problem is with Unicode characters. Unfortunately, I don't have WIN device available anytime soon. I need to postpone the PR a few days to find one 😓

I can try to run in - I will let you know. From the results I also see it's running some of the tests that should be disabled by default (like benchmark test). It's most likely because of the 'tox -> nox' migration that happened recently. I will fix that one too

There is problem with encoding, but it's not connected to your PR. All values passed to arguments/options are affected by it. I need to think about solution - it's not easy mix of argparse & encoding for specific platform

Another update - it might be also issue in how I read the test data. There is hope!

@rikerfi
Copy link
Contributor Author

rikerfi commented Aug 5, 2022

Something hassle with WIN environment. I try to fix that by guessing the problem is with Unicode characters. Unfortunately, I don't have WIN device available anytime soon. I need to postpone the PR a few days to find one sweat

I can try to run in - I will let you know. From the results I also see it's running some of the tests that should be disabled by default (like benchmark test). It's most likely because of the 'tox -> nox' migration that happened recently. I will fix that one too

There is problem with encoding, but it's not connected to your PR. All values passed to arguments/options are affected by it. I need to think about solution - it's not easy mix of argparse & encoding for specific platform

Ok, thanks for checking. I'll rollback the latest commit to keep PR simple.

@bhirsz
Copy link
Member

bhirsz commented Aug 5, 2022

Ups, for some reason the PR auto closed itself - working on the fix.

@rikerfi
Copy link
Contributor Author

rikerfi commented Aug 5, 2022

Ups, for some reason the PR auto closed itself - working on the fix.

No worries, I could create new one.

@bhirsz
Copy link
Member

bhirsz commented Aug 5, 2022

Ups, for some reason the PR auto closed itself - working on the fix.

I can't do it easily due to missing permissions (forked repo). Can you revert this PR somehow>? If not I can investigate more.

To get it working on windows you need to add encoding="utf-8" here:

with open(Path(__file__).parent / "custom_tests.yaml") as f:

and here:
with open(expected_file) as f:

@bhirsz bhirsz reopened this Aug 5, 2022
@rikerfi rikerfi marked this pull request as ready for review August 5, 2022 13:08
@rikerfi rikerfi requested a review from mnojek as a code owner August 5, 2022 13:08
@bhirsz
Copy link
Member

bhirsz commented Aug 7, 2022

Looks good now! I will leave few comments regarding lower/upper case, it's not strictly connected to your changed but my though in general for this rule

robocop/checkers/comments.py Outdated Show resolved Hide resolved
robocop/checkers/comments.py Outdated Show resolved Hide resolved
bhirsz
bhirsz previously approved these changes Aug 9, 2022
robocop/checkers/comments.py Outdated Show resolved Hide resolved
robocop/checkers/comments.py Outdated Show resolved Hide resolved
robocop/checkers/comments.py Show resolved Hide resolved
robocop/checkers/comments.py Outdated Show resolved Hide resolved
robocop/checkers/comments.py Outdated Show resolved Hide resolved
@rikerfi rikerfi requested a review from mnojek August 28, 2022 17:27
Copy link
Member

@mnojek mnojek left a comment

Choose a reason for hiding this comment

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

Great addition! Thanks, @rikerfi ! And sorry for being so nit-picky! 😉

@rikerfi
Copy link
Contributor Author

rikerfi commented Aug 29, 2022

Great addition! Thanks, @rikerfi ! And sorry for being so nit-picky! wink

Hah, no worries. Reviews are the right place for that 😄

@mnojek mnojek merged commit 07ac3da into MarketSquare:master Aug 29, 2022
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

4 participants