Skip to content

Commit b9ac553

Browse files
committed
added analysis_options.yaml and ran lint and applied changes
1 parent 626a2f6 commit b9ac553

11 files changed

+436
-352
lines changed

analysis_options.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# reference : https://dart.dev/tools/analysis
2+
3+
4+
include: package:lints/recommended.yaml
5+
6+
analyzer:
7+
exclude: [build/**]
8+
language:
9+
strict-raw-types: true
10+
strict-inference: true
11+
12+
# not including
13+
# strict-casts: true
14+
15+
16+
linter:
17+
rules:
18+
- use_super_parameters
19+
- cancel_subscriptions
20+
- close_sinks
21+
- combinators_ordering
22+
- comment_references
23+
- invalid_case_patterns
24+
- library_annotations
25+
- one_member_abstracts
26+
- only_throw_errors

bin/nostr_console.dart

+16-13
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Future<void> main(List<String> arguments) async {
9292
userPrivateKey = "";
9393
}
9494

95-
if( gUserLocation.length > 0){
95+
if( gUserLocation.isNotEmpty){
9696
print("Going to add $gUserLocation as the location tag with each post.");
9797
}
9898

@@ -118,7 +118,7 @@ Future<void> main(List<String> arguments) async {
118118

119119
// write informative message in case user is not using proper keys
120120
if( userPublicKey == gDefaultPublicKey) {
121-
print("You should ideally create your own private key and use it with ${gWarningColor}--prikey$gColorEndMarker program argument. ");
121+
print("You should ideally create your own private key and use it with $gWarningColor--prikey$gColorEndMarker program argument. ");
122122
print("Create a private key from ${gWarningColor}astral.ninja, @damusapp, or even from command line using `openssl rand -hex 32`.$gColorEndMarker.\n");
123123
print("npub/nsec keys can be converted to hex key format using https://damus.io/key");
124124
}
@@ -127,16 +127,16 @@ Future<void> main(List<String> arguments) async {
127127
if( argResults[relayArg] != null) {
128128
Set<String> userRelayList = Set.from(argResults[relayArg].split(","));
129129
Set<String> parsedRelays = {};
130-
userRelayList.forEach((relay) {
130+
for (var relay in userRelayList) {
131131
if(relay.startsWith(RegExp(r'^ws[s]?:\/\/'))) {
132132
parsedRelays.add(relay);
133133
} else {
134134
printWarning("The provided relay entry: \"$relay\" does not start with ws:// or wss://, omitting");
135135
}
136-
});
136+
}
137137

138138
// verify that there is at least one valid relay they provided, otherwise keep defaults
139-
if (parsedRelays.length > 0) {
139+
if (parsedRelays.isNotEmpty) {
140140
gListRelayUrls = parsedRelays;
141141
defaultServerUrl = gListRelayUrls.first;
142142
} else {
@@ -174,8 +174,9 @@ Future<void> main(List<String> arguments) async {
174174

175175
try {
176176
var terminalColumns = gDefaultTextWidth;
177-
if( stdout.hasTerminal )
177+
if( stdout.hasTerminal ) {
178178
terminalColumns = stdout.terminalColumns;
179+
}
179180

180181
// can be computed only after textWidth has been found
181182
if( gTextWidth > terminalColumns) {
@@ -184,7 +185,7 @@ Future<void> main(List<String> arguments) async {
184185
gNumLeftMarginSpaces = (terminalColumns - gTextWidth )~/2;
185186
} on StdoutException catch (e) {
186187
print("Cannot find terminal size. Left aligning by default.");
187-
if( gDebug > 0) log.info("${e.message}");
188+
if( gDebug > 0) log.info(e.message);
188189
gNumLeftMarginSpaces = 0;
189190
}
190191
// undo above if left option is given
@@ -262,10 +263,10 @@ Future<void> main(List<String> arguments) async {
262263
stdout.write('Reading events from ${whetherDefault}file.......');
263264

264265
// read file events and give the events to relays from where they're picked up later
265-
initialEvents = await readEventsFromFile(gEventsFilename);
266+
initialEvents = readEventsFromFile(gEventsFilename);
266267

267268
// count events
268-
initialEvents.forEach((element) { numFileEvents++;});
269+
for (var element in initialEvents) { numFileEvents++;}
269270
print("read $numFileEvents events from file $gEventsFilename");
270271
}
271272

@@ -338,7 +339,7 @@ Future<void> main(List<String> arguments) async {
338339
clearEvents();
339340

340341

341-
initialEvents.forEach((element) { element.eventData.kind == 1? numUserPosts++: numUserPosts;});
342+
for (var element in initialEvents) { element.eventData.kind == 1? numUserPosts++: numUserPosts;}
342343
numUserPosts -= numFilePosts;
343344
stdout.write("...done\n");//received $numUserPosts new posts made by the user\n");
344345

@@ -353,7 +354,9 @@ Future<void> main(List<String> arguments) async {
353354
getKindEvents([40, 41], gListRelayUrls, limitPerSubscription, getSecondsDaysAgo(limitSelfEvents));
354355
getKindEvents([42], gListRelayUrls, 3 * limitPerSubscription, getSecondsDaysAgo(limitOthersEvents));
355356

356-
initialEvents.forEach((e) => processKind3Event(e)); // first process the kind 3 event ; basically populate the global structure that holds this info
357+
for (var e in initialEvents) {
358+
processKind3Event(e);
359+
} // first process the kind 3 event ; basically populate the global structure that holds this info
357360

358361
Set<String> contacts = {};
359362
Set<String> pTags = {};
@@ -365,9 +368,9 @@ Future<void> main(List<String> arguments) async {
365368
// if contact list was found, get user's feed; also get some default contacts
366369
if (contactEvent != null ) {
367370
if(gDebug > 0) print("In main: found contact list: \n ${contactEvent.originalJson}");
368-
contactEvent.eventData.contactList.forEach((contact) {
371+
for (var contact in contactEvent.eventData.contactList) {
369372
contacts.add(contact.contactPubkey);
370-
});
373+
}
371374
} else {
372375
print("Could not find your contact list.");
373376
}

0 commit comments

Comments
 (0)