Refactored parseReqs into a new module Models.Requirement - #1808
Conversation
Coverage Report for CI Build 36342591068Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.7%) to 60.473%Details
Uncovered Changes
Coverage Regressions7 previously-covered lines in 2 files lost coverage.
Coverage Stats💛 - Coveralls |
| -- | Parses prerequisite strings into the Requirement datatype | ||
| parseReqs :: T.Text -> Req | ||
| parseReqs reqText = | ||
| let reqString = T.unpack reqText |
There was a problem hiding this comment.
You can call T.toLower on the input text to avoid using the Data.Char.toLower later on
|
|
||
| import Data.Char | ||
| import qualified Data.Text as T | ||
| import Database.Requirement |
There was a problem hiding this comment.
In general, we're moving towards always including explicit or qualified imports. For this module and WebParsing.ReqParser below, include the specific names being imported for this module.
| ("for (" ++ y ++ "),") | ||
| z | ||
| (parseReqs y) | ||
| (parseReqs (T.pack y)) |
There was a problem hiding this comment.
All of the test inputs are string literals, so instead of using T.pack here you should be able to just change the data type from String to T.Text throughout. We're using the FlexibleStrings compiler extension, which should automatically convert string literals to the T.Text type.
| import Database.Requirement | ||
| import Models.Requirement (parseReqs) |
There was a problem hiding this comment.
With this PR's change, let's also move this entire test module file to backend-test/Models/RequirementModelTests.hs, renaming it as necessary. This will help keep the test file organization aligned with the application code organization.
david-yz-liu
left a comment
There was a problem hiding this comment.
Nice work, @danielrafailov!
Proposed Changes
Refactored parseReqs into a new module Models.Requirement and updated its input type from String to Text.
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)