-
Notifications
You must be signed in to change notification settings - Fork 2
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
Rule Linting #2
Rule Linting #2
Conversation
- better error handling in TextRulesToJSON - no rules with obviously invalid predicates (comparing predicates using one of < <= > >=) - set of accepted RHS questions along with their expected answer type - set of accepted questions in LHS expressions along with their expected answer type - check for duplicate rules (rudimentary right now due to Rule's lack of Hashable)
The next step will be to amend the buddybuild_postclone.sh script in the core-news-shared-configs repo to clone, build and run the TextRulesToJSON program. I'll start on that script on Monday as well as the linter specification json file for our rules file. |
(.int, is Int), | ||
(.double, is Double), | ||
(.string, is String): return [] | ||
case (.bool, let x): return [(value, "type mismatch, \(question) should be compared to a bool, not a \(typeName(of: x))")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I've gotten this far without knowing about typeName(of:)
:-)
"city": "string" | ||
}, | ||
"rhs": { | ||
"favouriteTeam": ["Capitals", "Oilers", "Lightning", "Canucks"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"favoriteTeam"
case .comparison(.question, _, .question): | ||
return [] // not yet implemented | ||
case .comparison(.answer(let left), _, .answer(let right)) where type(of: left.value) == type(of: right.value): | ||
// it could be argued this shouldn't be allowed because it's silly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 agreed.
Rule Linting was added to the TextRulesToJSON program. Linting becomes a step of the .rules to .json conversion process.
Test coverage needs to improve further.
Example output:
This output was produced for this input:
Rules file:
Linter specification file: