Skip to content

Replace StringUtils + Partially cleanup FileUtils + Fix unit test #8688

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

Merged
merged 9 commits into from
Mar 26, 2019

Conversation

Pieter12345
Copy link
Contributor

  • Replace StringUtils by Apache's commons.lang3.StringUtils.
  • Remove unused methods from FileUtils that do not have an obvious use case or have an easy replacement (for example through Files).
  • Replace some calls to FileUtils with direct methods (functional code).

Having two StringUtils classes is confusing and not necessary since Apache's StringUtils provides all used functionality.

As for FileUtils; Apache commons.io contains a FileUtils class that can replace the copy / listFiles / delete methods, but some of these methods account for SOURCE_CONTROL_FOLDERS, which would make the current FileUtils implementation better if these SOURCE_CONTROL_FOLDERS actually exist in more than one use case.

The overall goal of this PR is to make the source code cleaner and more efficient without making functional changes.

- The file names in FILES_NOT_TO_COPY are full names and not partial names, so the check should not check if a file name contains such a name, but rather whether a file name fully matches such a name.
- Replaced the FILES_NOT_TO_COPY by a HashSet since this provides O(1) lookups, rather than O(n) lookups where n is the size of the set.
Updated due to new API methods than can be useful for this project.
The license remained the same.
Use Apache commons.lang3 instead of own implementation.
Use Apache commons.lang3 instead of own implementation.
The functionality in this class has been replaced with the Apache commons.lang3 dependency.
When having "autocrlf=input" (as described in the Building Arduino guide), the `.hex` files used in the test will be a different size due to the test expecting `\n` and git cloning as `\r\n`. This commit fixes this issue by removing cariage returns before running the test.
@Pieter12345 Pieter12345 force-pushed the codebase-consistency branch from b5bfcd3 to 9ed343b Compare March 22, 2019 01:15
Not wrapping these calls in FileUtils methods makes the code cleaner and easier to understand (FileUtils is very poorly documented, whereas direct calls contain proper documentation).
Remove unused FileUtils methods without obvious use case or for which a replacement exists in the Files or File class.
Fix CommandLineTest.testCommandLineVersion() failing on Windows due to Runtime.exec() returning `\r\n` line endings where the test expected `\n` line endings.
@Pieter12345 Pieter12345 force-pushed the codebase-consistency branch from 9ed343b to d5ea991 Compare March 22, 2019 04:58
@facchinm facchinm requested a review from cmaglie March 22, 2019 08:12
@facchinm facchinm added this to the Release 1.8.10 milestone Mar 25, 2019
@facchinm facchinm added the Component: IDE The Arduino IDE label Mar 25, 2019
@cmaglie cmaglie merged commit 933bbb3 into arduino:master Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants