Skip to content

Commit 8cc74de

Browse files
committed
#6 Move from pedantic to lints package and fix issues raised by the analyser.
1 parent 8b58b3d commit 8cc74de

File tree

8 files changed

+35
-44
lines changed

8 files changed

+35
-44
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# 1.0.10
44

5-
* Added Thumbnail as a Media Group property
5+
* BREAKING CHANGE: All enums corrected to camel-case to fit in with current lint rules.
6+
* Added Thumbnail as a Media Group property (@michael-yarzebinski).
67

78
# 1.0.9
89

analysis_options.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
include: package:pedantic/analysis_options.yaml
2-
3-
linter:
4-
rules:
5-
avoid_print: true
6-
cancel_subscriptions: true
7-
prefer_single_quotes: true
8-
prefer_const_constructors: true
9-
prefer_const_declarations: true
10-
require_trailing_commas: true
11-
use_super_parameters: true
1+
include: package:lints/recommended.yaml

lib/domain/dart_rss.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ extension SafeParseDateTime on DateTime {
2727
}
2828

2929
enum RssVersion {
30-
RSS1,
31-
RSS2,
32-
Atom,
33-
Unknown,
30+
rss1,
31+
rss2,
32+
atom,
33+
unknown,
3434
}
3535

3636
class WebFeed {
@@ -49,16 +49,16 @@ class WebFeed {
4949
static WebFeed fromXmlString(String xmlString) {
5050
final rssVersion = detectRssVersion(xmlString);
5151
switch (rssVersion) {
52-
case RssVersion.RSS1:
52+
case RssVersion.rss1:
5353
final rss1Feed = Rss1Feed.parse(xmlString);
5454
return WebFeed.fromRss1(rss1Feed);
55-
case RssVersion.RSS2:
55+
case RssVersion.rss2:
5656
final rss2Feed = RssFeed.parse(xmlString);
5757
return WebFeed.fromRss2(rss2Feed);
58-
case RssVersion.Atom:
58+
case RssVersion.atom:
5959
final atomFeed = AtomFeed.parse(xmlString);
6060
return WebFeed.fromAtom(atomFeed);
61-
case RssVersion.Unknown:
61+
case RssVersion.unknown:
6262
throw Error.safeToString(
6363
'Invalid XML String? We cannot detect RSS/Atom version.',
6464
);
@@ -144,13 +144,13 @@ class WebFeed {
144144
: feedRefs.first.getAttribute('xmlns')?.toLowerCase().contains('atom');
145145

146146
if (rdfRefs.isNotEmpty) {
147-
return RssVersion.RSS1;
147+
return RssVersion.rss1;
148148
} else if (rssRefs.isNotEmpty && ver != null && ver) {
149-
return RssVersion.RSS2;
149+
return RssVersion.rss2;
150150
} else if (feedRefs.isNotEmpty && xmlns != null && xmlns) {
151-
return RssVersion.Atom;
151+
return RssVersion.atom;
152152
}
153-
return RssVersion.Unknown;
153+
return RssVersion.unknown;
154154
}
155155
}
156156

lib/domain/rss1_feed.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import 'package:rss_dart/util/helpers.dart';
66
import 'package:xml/xml.dart';
77

88
enum UpdatePeriod {
9-
Hourly,
10-
Daily,
11-
Weekly,
12-
Monthly,
13-
Yearly,
9+
hourly,
10+
daily,
11+
weekly,
12+
monthly,
13+
yearly,
1414
}
1515

1616
class Rss1Feed {
@@ -39,15 +39,15 @@ class Rss1Feed {
3939
static UpdatePeriod? _parseUpdatePeriod(String? updatePeriodString) {
4040
switch (updatePeriodString) {
4141
case 'hourly':
42-
return UpdatePeriod.Hourly;
42+
return UpdatePeriod.hourly;
4343
case 'daily':
44-
return UpdatePeriod.Daily;
44+
return UpdatePeriod.daily;
4545
case 'weekly':
46-
return UpdatePeriod.Weekly;
46+
return UpdatePeriod.weekly;
4747
case 'monthly':
48-
return UpdatePeriod.Monthly;
48+
return UpdatePeriod.monthly;
4949
case 'yearly':
50-
return UpdatePeriod.Yearly;
50+
return UpdatePeriod.yearly;
5151
default:
5252
return null;
5353
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ dependencies:
1212

1313
dev_dependencies:
1414
test: ^1.16.4
15-
pedantic: ^1.10.0
15+
lints: ^4.0.0

test/rss1_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void main() {
3737
expect(feed.link, 'http://meerkat.oreillynet.com');
3838
expect(feed.description, 'Meerkat: An Open Wire Service');
3939

40-
expect(feed.updatePeriod, UpdatePeriod.Hourly);
40+
expect(feed.updatePeriod, UpdatePeriod.hourly);
4141
expect(feed.updateFrequency, 2);
4242
expect(feed.updateBase, DateTime.parse('2000-01-01T12:00+00:00'));
4343
});

test/rss_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void main() {
9898

9999
expect(
100100
feed.items.first.content!.value,
101-
'<img alt="unit test image" width=\"1000\" height=\"690\" src=\"https://test.com/image_link\"/> Test content<br />',
101+
'<img alt="unit test image" width="1000" height="690" src="https://test.com/image_link"/> Test content<br />',
102102
);
103103
expect(
104104
feed.items.first.content!.images.first,
@@ -439,14 +439,14 @@ void main() {
439439
expect(feed.podcastIndex?.value![0]!.recipients![0]!.name, 'podcaster');
440440
expect(feed.podcastIndex?.value![0]!.recipients![0]!.type, 'node');
441441
expect(feed.podcastIndex?.value![0]!.recipients![0]!.address,
442-
'ABCDEFGHIJLKMNOPQRSTUVWXYZ');
442+
'ABCDEFGHIJLKMNOPQRSTUVWXYZ',);
443443
expect(feed.podcastIndex?.value![0]!.recipients![0]!.split, 99);
444444

445445
expect(
446-
feed.podcastIndex?.value![0]!.recipients![1]!.name, 'hosting company');
446+
feed.podcastIndex?.value![0]!.recipients![1]!.name, 'hosting company',);
447447
expect(feed.podcastIndex?.value![0]!.recipients![1]!.type, 'node');
448448
expect(feed.podcastIndex?.value![0]!.recipients![1]!.address,
449-
'abcdefghijklmnopqrstuvwxyz');
449+
'abcdefghijklmnopqrstuvwxyz',);
450450
expect(feed.podcastIndex?.value![0]!.recipients![1]!.split, 1);
451451

452452
expect(feed.podcastIndex!.guid, '20a14457-0993-49b8-a37a-18384e7f91f8');
@@ -469,7 +469,7 @@ void main() {
469469
expect(chapters1?.type, 'application/json');
470470

471471
expect(item1.podcastIndex!.license!.url,
472-
'https://www.mytestlicense.org/lic.html');
472+
'https://www.mytestlicense.org/lic.html',);
473473
expect(item1.podcastIndex!.license!.license, 'my-test-license-v1');
474474

475475
expect(soundbite1.length, 1);

test/webfeed_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ void main() {
2727

2828
test('it can detect Atom feed.', () {
2929
final version = WebFeed.detectRssVersion(atomXmlString);
30-
expect(version, RssVersion.Atom);
30+
expect(version, RssVersion.atom);
3131
});
3232

3333
test('it can detect RSS1.0 feed.', () {
3434
final version = WebFeed.detectRssVersion(rss1XmlString);
35-
expect(version, RssVersion.RSS1);
35+
expect(version, RssVersion.rss1);
3636
});
3737

3838
test('it can detect RSS2.0 feed.', () {
3939
final version = WebFeed.detectRssVersion(rss2XmlString);
40-
expect(version, RssVersion.RSS2);
40+
expect(version, RssVersion.rss2);
4141
});
4242

4343
test('it can parse Atom feed.', () {

0 commit comments

Comments
 (0)