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

[cloc] Fix cloc error due to mulitple word language-name #46

Merged
merged 1 commit into from
Jul 21, 2019

Conversation

inishchith
Copy link
Contributor

@inishchith inishchith commented Jul 20, 2019

@valeriocos As I was working on large repository evaluation(inishchith/gsoc#12 (comment)), enter this error in logic under cloc analyzer which depends on reporting of results based on position in the list.

  • For instance, in the following example 3rd element:
    1. represents number of blank lines (int)
    2. here it's part of language name (str)
i. ['YAML', '1', '3', '0', '16']
ii. ['Bourne', 'Again', 'Shell', '1', '13', '18', '105']   <--------- Error

This PR fixes the error by picking the elements from the last(right to left). Please let me know what you think :)

Signed-off-by: inishchith inishchith@gmail.com

@valeriocos valeriocos self-requested a review July 21, 2019 07:27
Copy link
Member

@valeriocos valeriocos left a comment

Choose a reason for hiding this comment

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

Thank you @inishchith for the PR. It looks good, I have just a couple of minor comments.

  • Could you increase the version number of the cloc analyzer?
  • It would be possible to add some assertions to the existing tests (test_cloc.py) to be sure we are correctly parsing blanks, comments and loc?

@inishchith
Copy link
Contributor Author

@valeriocos

Could you increase the version number of the cloc analyzer?

Sure. Done!

It would be possible to add some assertions to the existing tests (test_cloc.py) to be sure we are correctly parsing blanks, comments and loc?

It's possible by implementing the same logic at the test side. I'll add it, Please let me know if there's a better way of doing it.

Thanks!

@valeriocos
Copy link
Member

Sure. Done!

Thanks

It's possible by implementing the same logic at the test side. I'll add it, Please let me know if there's a better way of doing it.

I apologize for being unclear. I meant to do something like:

    def test_analyze(self):
        """Test whether cloc returns the expected fields data"""

        cloc = Cloc()
        kwargs = {'file_path': os.path.join(self.data_path, ANALYZER_TEST_FILE)}
        result = cloc.analyze(**kwargs)

        self.assertIn('blanks', result)
        self.assertTrue(type(result['blanks']), int)
        self.assertTrue(result['blanks'], 27) <--
        self.assertIn('comments', result)
        self.assertTrue(type(result['comments']), int)
        self.assertTrue(result['comments'], 31) <--
        self.assertIn('loc', result)
        self.assertTrue(type(result['loc']), int)
        self.assertTrue(result['loc'], 67) <--

This commit fixes error produced due to language names with multiple
words

Signed-off-by: inishchith <inishchith@gmail.com>
@inishchith
Copy link
Contributor Author

@valeriocos No worries. Thanks for the clarification! I've made the changes.

@valeriocos valeriocos marked this pull request as ready for review July 21, 2019 13:47
@valeriocos valeriocos self-requested a review July 21, 2019 13:47
Copy link
Member

@valeriocos valeriocos left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @inishchith

@valeriocos valeriocos merged commit 0e3fd71 into chaoss:master Jul 21, 2019
valeriocos added a commit that referenced this pull request Jul 21, 2019
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