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/multiline file boundary issue #277

Merged

Conversation

francoisvn
Copy link
Contributor

I discovered a bug where the multiline status of one file can impact a later file. I noticed this with the IndentationCharacterCheck, but I think it would be present in other checks that extend LineCheckBase. No idea if this is the correct way to fix this, but it resolved the issue for me. Unfortunately I can't share the exact code, but I can try create a small test case for reproduction if that would help.

Similar issues, where checks can cross file boundaries, are probably still there with other checks (maybe even still these). It doesn't seem like there is generally anything to prevent against this. A more general solution is to re-create each check with each file (might be slow), or have something like an init() function that gets called before each file, and move most/all of the code in the constructors there.

@codecov-io
Copy link

codecov-io commented Aug 17, 2016

Current coverage is 89.68% (diff: 83.33%)

Merging #277 into dev will increase coverage by 0.05%

@@                dev       #277   diff @@
==========================================
  Files           112        112          
  Lines          7385       7387     +2   
  Methods           0          0          
  Messages          0          0          
  Branches        287        286     -1   
==========================================
+ Hits           6619       6625     +6   
+ Misses          511        508     -3   
+ Partials        255        254     -1   

Sunburst

Powered by Codecov. Last update 9d30630...337ee47

@adireddy
Copy link
Member

Thanks @francoisvn. Can you add the tests here pls just to make sure it doesn't break anything.

@francoisvn
Copy link
Contributor Author

I added 2 tests. The first would have previously failed, but my workaround fixes it (testFileBoundaryIndentation()) and the second still fails (testMultilineQuoteIndentation()).

So there are 2 underlying issues, which I haven't properly addressed in this PR (cause I don't know the codebase well enough):

  • Checks can cross file boundaries.
  • Multiline detection in LineCheckBase is inherently buggy.

@francoisvn
Copy link
Contributor Author

Should I maybe remove the test that fails and create an issue for that? It's not a trivial fix, which is why I haven't done it myself.

In addition, it feels like the file boundary issue requires a bit of refactoring to properly fix.

@Gama11
Copy link
Member

Gama11 commented Aug 19, 2016

Yes, can't merge a PR that introduces failing tests.

This reverts commit 543846f.
@francoisvn
Copy link
Contributor Author

Ok, I've reverted that test and created an issue here: #278

I still think the file boundary issue I've mentioned needs further investigation, but reporting an issue for that doesn't seem sensible, so I don't know how to take it further. I don't know the codebase well enough to know how best to fix it, and it's a non-trivial change, but I think it's important that it gets investigated. Recommendations for what I can do are welcome.

@Gama11 Gama11 added the bug label Aug 21, 2016
@Gama11
Copy link
Member

Gama11 commented Aug 21, 2016

Thanks!

@Gama11 Gama11 merged commit 0b052e5 into HaxeCheckstyle:dev Aug 21, 2016
@francoisvn francoisvn deleted the fix/multiline-file-boundary-issue branch August 22, 2016 14:12
@francoisvn
Copy link
Contributor Author

Great. What should I do about the file boundary issue, or is that not important? Should I create an issue? It seems rather important to me, as someone that would like to rely on this tool...

@Gama11
Copy link
Member

Gama11 commented Aug 22, 2016

Creating an issue definitely can't hurt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants