maat-scripts icon indicating copy to clipboard operation
maat-scripts copied to clipboard

fix: encoding errors are thrown for non UTF-8 files with special characters

Open wonderbird opened this issue 2 years ago • 1 comments

Note

The test test_git_complexity_trend_should_process_non_utf8_encoded_files will fail, if the git commit hash changes for commit f39cd09 (test: complexity_trend for iso-8859-1 encoded files must not throw error), because that commit hash is hard coded into the test. If that happens, I would fix the issue later.

Summary

While analyzing files using ISO-8859-1 encoding, I encountered errors thrown by methods processing the files.

Details

This PR fixes some of the read / parse functions so that no errors are thrown.

At the moment the code is configured to replace special characters in non unicode files by '?'. In the analysis functions to measure complexity and complexity trend. This shouldn't have any impact on the results.

wonderbird avatar May 29 '22 11:05 wonderbird

Hello @adamtornhill ,

This PR is now ready for being merged.

Please let me know if you would prefer a different way of testing in test_git_complexity_trend_should_process_non_utf8_encoded_files.

On the one hand I dislike the hard coded commit sha, on the other hand the test follows the use case quite well and is (hopefully) easy to understand.

Kind Regards, Stefan

wonderbird avatar May 29 '22 12:05 wonderbird