keyko-io / filecoin-verifier-tools

Javascript implementation of a HAMT using ipld
Apache License 2.0
6 stars 5 forks source link

refactor regexes for filecoin verifier tools #149

Closed fabriziogianni7 closed 1 year ago

fabriziogianni7 commented 1 year ago

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

fabriziogianni7 commented 1 year ago

@huseyincansoylu you can delete function parseOtherInfoIssue we are not using this

fabriziogianni7 commented 1 year ago

@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

fabriziogianni7 commented 1 year ago

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 --> https://github.com/keyko-io/filecoin-verifier-tools/blob/571f3fdff2bd41da1877a14ad1ffb37ea7cc46bb/utils/large-issue-parser.js#L6 https://github.com/keyko-io/filecoin-verifier-tools/blob/571f3fdff2bd41da1877a14ad1ffb37ea7cc46bb/utils/large-issue-parser.js#L204 https://github.com/keyko-io/filecoin-verifier-tools/blob/571f3fdff2bd41da1877a14ad1ffb37ea7cc46bb/utils/large-issue-parser.js#L166 (for the last 2: https://github.com/keyko-io/filecoin-verifier-tools/blob/571f3fdff2bd41da1877a14ad1ffb37ea7cc46bb/utils/large-issue-parser.js#L166 is doing the job)

huseyincansoylu commented 1 year ago

@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 ?

jbesraa commented 1 year ago

https://github.com/keyko-io/filecoin-large-clients-onboarding-bot/pull/119