Skip to content

Add has_public_example check#470

Merged
wilzbach merged 1 commit intomasterfrom
has_public_example
Jun 28, 2017
Merged

Add has_public_example check#470
wilzbach merged 1 commit intomasterfrom
has_public_example

Conversation

@wilzbach
Copy link
Member

This adds a check for public declaration without a documented unittest.

As Dscanner will hopefully support selective imports soon, this is intended to be a replacement for the version currently used by Phobos (e.g. https://github.com/dlang/tools/blob/master/styles/has_public_example.d, https://github.com/dlang/phobos/blob/548630d2a9ba95f079193d7b47ed8cd685c0f7c8/posix.mak#L602).

if (!isPublic(decl.attributes))
continue;

bool hasDdocHeader = hasDdocHeader(decl);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const bool

override void visit(const Module mod)
{
Declaration lastDecl;
bool hasPublicUnittest = true; // reset on lastDecl assignment
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather name this variable hasNoPublicTest and change the related relational expressions, because

  • then you'll can remove the initializer.
  • if you look at the use spots, you always negate the variable.

hence you'll have the same meaning with less complexity.

@wilzbach wilzbach force-pushed the has_public_example branch from 497a7e4 to de814b8 Compare June 25, 2017 07:25
@wilzbach
Copy link
Member Author

I'd rather name this variable hasNoPublicTest and change the related relational expressions, because

Excellent idea!

@wilzbach wilzbach force-pushed the has_public_example branch from de814b8 to e065d07 Compare June 25, 2017 07:30
A check for public declaration without a documented unittest.
@wilzbach
Copy link
Member Author

Merging this as this is a new, by-default disabled check & I can "battle-test" it on Phobos over the next weeks.

@wilzbach wilzbach merged commit ba75110 into master Jun 28, 2017
@wilzbach wilzbach deleted the has_public_example branch June 28, 2017 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant