Skip to content

Comments

Handle empty doc comments ("///") on unittests#401

Merged
dlang-bot merged 3 commits intodlang-community:masterfrom
MoonlightSentinel:empty-ddoc
May 4, 2020
Merged

Handle empty doc comments ("///") on unittests#401
dlang-bot merged 3 commits intodlang-community:masterfrom
MoonlightSentinel:empty-ddoc

Conversation

@MoonlightSentinel
Copy link
Contributor

Currently there is no way to differentiate between the following unittests because unittest.comment is null for both:

unittest {}

///
unittest {}

This PR ensures that comment is non-null if a declaration has an empty doc comment.

@codecov
Copy link

codecov bot commented May 3, 2020

Codecov Report

Merging #401 into master will increase coverage by 0.15%.
The diff coverage is 96.49%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #401      +/-   ##
==========================================
+ Coverage   76.28%   76.43%   +0.15%     
==========================================
  Files           9        9              
  Lines        7172     7224      +52     
==========================================
+ Hits         5471     5522      +51     
- Misses       1701     1702       +1     
Impacted Files Coverage Δ
src/dparse/ast.d 57.80% <91.66%> (+1.91%) ⬆️
src/dparse/trivia.d 99.45% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b717d6...8ad3c46. Read the comment docs.

MoonlightSentinel added a commit to MoonlightSentinel/tools that referenced this pull request May 3, 2020
`hasDdocHeader` was only called if decl.unittest_ wasn't null and
hence only executed the first if-branch.

The remainder of that method is obsolete because dparse sets `comment`
even for empty ddoc comments (see dlang-community/libdparse#401).
MoonlightSentinel added a commit to MoonlightSentinel/tools that referenced this pull request May 3, 2020
`hasDdocHeader` was only called if `decl.unittest_` wasn't null and
hence only executed the first if-branch.

The remainder of that method is obsolete because dparse sets `comment`
even for empty ddoc comments (see dlang-community/libdparse#401).

Relying on dparse also removes some false positives/negatives, e.g.

```
///
// Some comment
unittest {} // Ignored

////////////////////////////////////////////////////////////////////////////////
// Unit Tests
////////////////////////////////////////////////////////////////////////////////

unittest {} // Extracted
```
MoonlightSentinel added a commit to MoonlightSentinel/tools that referenced this pull request May 3, 2020
`hasDdocHeader` was only called if `decl.unittest_` wasn't null and
hence only executed the first if-branch.

The remainder of that method is obsolete because dparse sets `comment`
even for empty ddoc comments (see dlang-community/libdparse#401).

Relying on dparse also removes some false positives/negatives, e.g.

```
///
// Some comment
unittest {} // Ignored

////////////////////////////////////////////////////////////////////////////////
// Unit Tests
////////////////////////////////////////////////////////////////////////////////

unittest {} // Extracted
```
@dlang-bot dlang-bot merged commit bf7c4c1 into dlang-community:master May 4, 2020
@MoonlightSentinel MoonlightSentinel deleted the empty-ddoc branch May 4, 2020 07:05
MoonlightSentinel added a commit to MoonlightSentinel/tools that referenced this pull request Jun 24, 2020
`hasDdocHeader` was only called if `decl.unittest_` wasn't null and
hence only executed the first if-branch.

The remainder of that method is obsolete because dparse sets `comment`
even for empty ddoc comments (see dlang-community/libdparse#401).

Relying on dparse also removes some false positives/negatives, e.g.

```
///
// Some comment
unittest {} // Ignored

////////////////////////////////////////////////////////////////////////////////
// Unit Tests
////////////////////////////////////////////////////////////////////////////////

unittest {} // Extracted
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants