-
Notifications
You must be signed in to change notification settings - Fork 8
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
test: add test for unnamed returns #22
Conversation
Co-authored-by: Gas <[email protected]>
test/validator.test.ts
Outdated
expect(result).toEqual([`@return missing for unnamed return №2`]); // only 1 warning | ||
}); | ||
|
||
it('should not warn of extra natspec tags', () => { |
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.
The code for this case won't compile, right? If so we can delete the test.
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.
The code for this case won't compile, right? If so we can delete the test.
right, and a couple of more tests
test/validator.test.ts
Outdated
}; | ||
|
||
const result = validator.validate(node, natspec); | ||
expect(result).toEqual(['@return _isMagic is missing']); // 1 warning |
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.
The warning is misleading here. As a user, I will check that the @return _isMagic
is there and think that the tool has mixed something up. Some will realize it's because of the order but many won't. We should either make it the message or avoid printing any warnings in case of incorrect ordering.
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.
The warning is misleading here. As a user, I will check that the
@return _isMagic
is there and think that the tool has mixed something up. Some will realize it's because of the order but many won't. We should either make it the message or avoid printing any warnings in case of incorrect ordering.
this won't compile as well so I'll delete it
@@ -95,7 +95,7 @@ export function parseNodeNatspec(node: NodeToProcess): Natspec { | |||
result.inheritdoc = { content: tagMatch[2] }; | |||
} | |||
} else if (tagName === 'param' || tagName === 'return') { | |||
const tagMatch = line.match(/^\s*@(\w+) *(\w+) (.*)$/); | |||
const tagMatch = line.match(/^\s*@(\w+) *(\w*) *(.*)$/); |
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.
Good job catching this 👍🏻
sample-data/ParserTest.sol
Outdated
/// fun fact: there are extra spaces after the 1st return | ||
/// @return | ||
/// @return | ||
function functionUnnamedEmptyReturn() external view returns (uint256, bool){ |
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.
Could you move this function to ParserTestFunny
? It's the contract that acts as a collection of weird natspec.
Co-authored-by: Gas <[email protected]>
🤖 Linear
Closes BES-248
ToDo:
[ ] Advanced parameters search algorithm (not linear)