refactor regexes for filecoin verifier tools
fabriziogianni7 opened this issue · comments
Description
one of the function this library has is to parse the content of the github issue.
we get as an input the body of the issue and we extract some info from it.
as you can see now, the parsing functions are very long and we are hardcoding the regexes, and using some helper function like this
To do
all the content passed in (the issue body) should be trimmered and parsed using lookahead / lookbehind
there is an example of how can the parsing function be.
it is a little bit more dynamic:
for (const [k, v] of Object.entries(data)) {
const rg = new RegExp(`(?<=${v})(.*?)(?=#)`) //building the regex dynamically
const regexIsNull = !trimmed.match(rg) || !trimmed.match(rg).length || !trimmed.match(rg)[0] //checking if the return value is null
[other stuff]
}
note that here we're not using any helper function to execute the regex
I suggest to use https://regex101.com/ to test regex you build
The goal
- have less code and a clearer view of the regexes.
- all the test cases should pass
- all the functions should return the same object structure than before
@huseyincansoylu
you can delete function parseOtherInfoIssue
we are not using this
@huseyincansoylu
I made some PR you need to have a look bc you need to ad a regex in your refactoring: it is needed to parse the uuid from the requests.
https://github.com/keyko-io/filecoin-verifier-tools/pull/153/files
i’m merging this in master, but you should add this to the refactor of the corresponding function
also adding a comment in your issue so you don’t forget
I also suggest to go through all the project and see if we need all of the functions over there cause I believe some are not used anymore, for instance the following -->
(for the last 2: is doing the job)
@jbesraa
https://github.com/keyko-io/filecoin-large-clients-onboarding-bot/blob/6b9d2bc9e3ceff0ee2e14f7d959b55b13ff119b6/src/index.ts#L355
I am refactroing verifier-tools, instead of "parseApproveComment" function, we want to use "parseApprovedRequestWithSignerAddress" this function.
can you please adjust the ldn repo ?