linter icon indicating copy to clipboard operation
linter copied to clipboard

`package_api_docs` false negative

Open afgriffiths opened this issue 3 years ago • 7 comments

Steps to Reproduce

Create a new Dart project (designed to be a consumable package). Add the following contents to analysis_options.yaml

linter:
  rules:
    - avoid_classes_with_only_static_members
    - package_api_docs

In lib create a new file called date_utils.dart with the following contents (lifted straight from the bad example at the page for the avoid_classes_with_only_static_members lint):

class DateUtils {
  static DateTime mostRecent(List<DateTime> dates) {
    return dates.reduce((a, b) => a.isAfter(b) ? a : b);
  }
}

Expected behaviour

Running dart analyze in the directory should complain of a violation of both avoid_classes_with_only_static_members and package_api_docs since:

  • DateUtils is a class with only static members
  • The whole date_utils.dart file contains no doc comments and it's publicly accessible (since it lives in lib)

Actual behaviour

Run dart analyze in the directory and observe that no violations are found.

Environment Information

Dart Version: 2.12.3 Operating System: Windows 10 64-bit

afgriffiths avatar May 01 '21 22:05 afgriffiths

@pq @bwilkerson

scheglov avatar May 10 '21 19:05 scheglov

See also #2731 for the avoid_classes_with_only_static_members false negative. Not sure about the package_api_docs issue...

pq avatar Jul 06 '21 18:07 pq

The avoid_classes_with_only_static_members issue has been fixed.

pq avatar Nov 15 '22 00:11 pq

Same here, package_api_docs does not work sometimes...

fzyzcjy avatar Nov 20 '23 13:11 fzyzcjy

As of https://github.com/dart-lang/linter/issues/3395, this lint is essentially a no-op. Assuming interest, we could revisit I think given the new workspace support. Alternatively we should deprecate and remove.

/fyi @bwilkerson @keertip

pq avatar Apr 22 '24 17:04 pq

What is the difference between package_api_docs and public_member_api_docs? (The docs for those lints aren't very clear.)

bwilkerson avatar Apr 22 '24 18:04 bwilkerson

https://github.com/dart-lang/linter/issues/1373 😄

pq avatar Apr 22 '24 18:04 pq