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

Fix: Match files_sub_directory as a prefix #1765

Merged

Conversation

giner
Copy link
Contributor

@giner giner commented Aug 19, 2022

Proposed Changes

Properly match files_sub_directory as a prefix instead of partial string matching.

Before

  • If directory named "files_sub_directory" exists then all files
    matching "files_sub_directory" are selected. For example if
    files_sub_directory is set to "dir" and dir exists under the workspace
    directory then "mode/direct/file.yml" and "new_directory/f.yml" will
    be selected

After

  • If directory named "files_sub_directory" exists then all files
    which names start with "files_sub_directory" are selected. For example if
    files_sub_directory is set to "dir" (or "./dir" or "dir/" or "./dir/")
    and dir exists under the workspace directory then "dir/file.yml" will be
    selected but not "new_directory/f.yml" and not "some/dir/f.yml"

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

@giner giner requested a review from nvuillam as a code owner August 19, 2022 10:22
@giner giner force-pushed the dont_do_partial_match_for_files_sub_directory branch 5 times, most recently from 4538f1b to fb6ff05 Compare August 19, 2022 14:36
@nvuillam
Copy link
Member

it seems it does not work with some test classes using files_sub_directory...

Maybe something to play with workspace MegaLinter object attribute ?

@giner
Copy link
Contributor Author

giner commented Aug 21, 2022

it seems it does not work with some test classes using files_sub_directory...

Maybe something to play with workspace MegaLinter object attribute ?

I'm trying to find an easy way to run a subset of tests locally. Any hints?

@nvuillam
Copy link
Member

Instructions are here :)

https://oxsecurity.github.io/megalinter/latest/contributing/

To locally run test classes and debug with breakpoints , you can use VsCode extension Test Explorer

image

If you use PyCharm it is native

@giner
Copy link
Contributor Author

giner commented Aug 21, 2022

I've seen the doc before and it was saying that I had to trigger a pipeline in any case to build a container. The only thing I could do (according to the docs) is limiting what to build (quick build) and what to test but I'd have to wait an approval every time and then the time to be built and be tested. I'll try vscode or pycharm.

@nvuillam
Copy link
Member

@giner the pipeline is indeed mandatory, but you can locally run without the docker image if you have installed the linter globally in your computer
The conditions are not the same than in CI with built image, but they are often similar so what works locally has good chances to work in CI :)

@giner giner force-pushed the dont_do_partial_match_for_files_sub_directory branch from fb6ff05 to 7d01b6a Compare August 22, 2022 12:32
@nvuillam
Copy link
Member

I think you must solve conflicts before I can accept the CI jobs ^^

@giner giner force-pushed the dont_do_partial_match_for_files_sub_directory branch from 7d01b6a to 6e181e7 Compare August 22, 2022 12:54
Properly match `files_sub_directory` as a prefix instead of partial string matching.

Before

- If directory named "files_sub_directory" exists then all files
  matching "files_sub_directory" are selected. For example if
  files_sub_directory is set to "dir" and dir exists under the workspace
  directory then "mode/direct/file.yml" and "new_directory/f.yml" will
  be selected

After

- If directory named "files_sub_directory" exists then all files
  which names start with "files_sub_directory" are selected. For example if
  files_sub_directory is set to "dir" (or "./dir" or "dir/" or "./dir/")
  and dir exists under the workspace directory then "dir/file.yml" will be
  selected but not "new_directory/f.yml" and not "some/dir/f.yml"
@giner giner force-pushed the dont_do_partial_match_for_files_sub_directory branch from 6e181e7 to e3666a1 Compare August 22, 2022 14:07
Copy link
Member

@nvuillam nvuillam left a comment

Choose a reason for hiding this comment

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

Good catch, thanks a lot for your contribution :)

@nvuillam nvuillam merged commit aed08f6 into oxsecurity:main Aug 22, 2022
@giner giner deleted the dont_do_partial_match_for_files_sub_directory branch August 22, 2022 15:28
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.

2 participants