Skip to content

Conversation

@AmineBarrak
Copy link

@AmineBarrak AmineBarrak commented Sep 17, 2018

Hi,

I presented here a solution in Python. Where I use Regular expressions to catch (FileName, number of deleted lines, number of added lines, number of regions and the called functions and their occurrence).
The function result takes one diff file path, then it starts reading it line by line, and testing on each line if we found a match with the regular expressions that we are collecting. Even more for optimisation, we are ignoring lines where we are sure that we will not have a match with any of our regular expressions. In the end, this function returns a list of founded files, the number of deleted, added and region lines and a list of functions that were called in the diff file.
In the main function, we are considering files in the repository diffs, and read them one by one and executing result function to collect needed information. Then, combine all results together. For the list of called functions, we used a dictionary to map the occurrence of each function with the function name.
Finally, we report all results in files.

  • Function calls and their occurrences in "calls.txt"
  • List of all occurred files in diffs in "list_files.txt"
  • Statics results including number of added, deleted and regions lines in "stat.txt"

After putting results of python script in files, we used Golang main function to read these files and putting results in the result struct.

Sincerely,

Amine Barrak
Research master in Software Engineering
[email protected]

@MathieuNls
Copy link
Owner

Hi,
Could you comment a bit on the approach you took ? See #6 or #4 for reference.
M.

challenge.py Outdated
regex_Del = "^-(?!--).*"
regex_Add = "^\+(?!\+\+).*"
regex_region = "^@@ -\d+(?:,\d+)? \+\d+(?:,\d+)?\ @@[ ]?.*"
regex_functionCall = "([\w]+)(?=\()"
Copy link
Owner

Choose a reason for hiding this comment

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

This won't catch functions calls. Something like (?![a-z])[^\:,>,\.]([a-z,A-Z]+[_]*[a-z,A-Z]*)+[(] would.

Copy link
Author

Choose a reason for hiding this comment

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

Hi Mathieu,

I did a comment of my approach,
I tried to use your Regex, but it took so much time in the script without giving result,
Actually, I used my regex using some example here on the following link: https://regex101.com/r/n7B3ox/5
it is catching statement too, but I filter them in the code.

Kind regards,
Amine

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.

4 participants