Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling lint usage and fixing static analysis error #218

Merged
merged 11 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# TODO remove the || true when this should be enforced
# Right now it is just informational
- name: "Lint"
run: "flutter analyze || true"
run: "flutter analyze"

- name: "Style check"
run: "flutter format --set-exit-if-changed lib test"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ Builds for local instances:
flutter build linux -t lib/main_local.dart
```

If flutter is not used for web application, worth to set:
```bash
flutter config --no-enable-web
```

Checkout detail instructions how to [sign releases](https://github.com/LeastAuthority/destiny/blob/main/doc/releases.md).

### Starting the wormhole services locally
Expand Down
29 changes: 29 additions & 0 deletions analysis_options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
8 changes: 4 additions & 4 deletions lib/constants/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ String projectLink(String path, {String? blob}) {
return 'https://github.com/LeastAuthority/destiny/blob/$targetBlob/$path';
}

final String FEEDBACK_LINK = projectLink('FAQ.md#contact', blob: "main");
final String FAQ_LINK = projectLink('FAQ.md', blob: "main");
final String PRIVACY_LINK = projectLink('PRIVACY-POLICY.md', blob: "main");
final String TERMS_LINK = projectLink('TERMS.md');
final String feedbackLink = projectLink('FAQ.md#contact', blob: "main");
final String fagLink = projectLink('FAQ.md', blob: "main");
final String privacyLink = projectLink('PRIVACY-POLICY.md', blob: "main");
final String termsLink = projectLink('TERMS.md');

const String ERR_WRONG_CODE_RECEIVER = """Oops..
If you’re sure this is the right code: Either the sender is no longer connected, or the code was already used.
Expand Down
1 change: 0 additions & 1 deletion lib/main_la.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:dart_wormhole_william/client/native_client.dart';
import 'package:destiny/constants/app_constants.dart';

import 'main.dart';

Expand Down
1 change: 0 additions & 1 deletion lib/main_local.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:dart_wormhole_william/client/native_client.dart';

import 'constants/app_constants.dart';
import 'main.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion lib/views/desktop/introduction-slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class IntroScreenState extends State<IntroScreen> {
showPrevBtn: false,
showDoneBtn: false,
desktopActionButtonEnabled: true,
termsLink: TERMS_LINK,
termsLink: termsLink,
onDonePress: this.onDonePress,
colorDot: Theme.of(context).scaffoldBackgroundColor,
colorActiveDot: Theme.of(context).colorScheme.secondary,
Expand Down
2 changes: 1 addition & 1 deletion lib/views/desktop/send/widgets/DTButtonWithIcon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DTButtonWithIcon extends StatelessWidget {
}
},
style: ElevatedButton.styleFrom(
primary: Theme.of(context).scaffoldBackgroundColor,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
minimumSize: Size.zero,
maximumSize: Size.zero,
padding: EdgeInsets.zero,
Expand Down
1 change: 1 addition & 0 deletions lib/views/desktop/send/widgets/DTSelectOrDropAFile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import '../../../../constants/app_constants.dart';
import 'DTDropAFile.dart';

// ignore: must_be_immutable
class DTSelectOrDropAFile extends StatefulWidget {
final Future<void> Function() onFileSelected;
final Future<void> Function(f.File) onFileDropped;
Expand Down
3 changes: 2 additions & 1 deletion lib/views/desktop/splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import 'package:destiny/constants/app_constants.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

// ignore: must_be_immutable
class Splash extends StatelessWidget {
SharedPreferences? prefs;
Future isItAppFirstLunch() async {
prefs = await SharedPreferences.getInstance();
bool _seen = (prefs?.getBool(SEEN) ?? false);
final bool _seen = (prefs?.getBool(SEEN) ?? false);
return _seen;
}

Expand Down
4 changes: 0 additions & 4 deletions lib/views/mobile/Info.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:destiny/constants/app_constants.dart';
import 'package:destiny/constants/asset_path.dart';
import 'package:destiny/settings.dart';
import 'package:destiny/widgets/prefs_edit.dart';
import 'package:destiny/views/mobile/widgets/buttons/Button.dart';
Expand Down Expand Up @@ -42,9 +41,6 @@ class _InfoState extends State<Info> {

@override
Widget build(BuildContext context) {
final headingStyle =
Theme.of(context).textTheme.headline6?.copyWith(fontFamily: MONTSERRAT);

return Scaffold(
appBar: CustomAppBar(
title: INFO,
Expand Down
3 changes: 1 addition & 2 deletions lib/views/mobile/introduction-slider.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:destiny/constants/app_constants.dart';
import 'package:destiny/constants/asset_path.dart';
import 'package:destiny/views/mobile/send/send.dart';
import 'package:dart_wormhole_william/client/native_client.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:intro_slider/intro_slider.dart';
Expand Down Expand Up @@ -79,7 +78,7 @@ class IntroScreenState extends State<IntroScreen> {
slides: this.slides,
showSkipBtn: false,
showNextBtn: false,
termsLink: TERMS_LINK,
termsLink: termsLink,
showPrevBtn: false,
showDoneBtn: false,
onDonePress: this.onDonePress,
Expand Down
1 change: 1 addition & 0 deletions lib/views/mobile/splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:destiny/constants/app_constants.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

// ignore: must_be_immutable
class Splash extends StatelessWidget {
SharedPreferences? prefs;
Future isItAppFirstLunch() async {
Expand Down
2 changes: 1 addition & 1 deletion lib/views/mobile/widgets/buttons/ButtonWithIcon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ButtonWithIcon extends StatelessWidget {
}
},
style: ElevatedButton.styleFrom(
primary: Theme.of(context).scaffoldBackgroundColor,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
2 changes: 1 addition & 1 deletion lib/views/shared/file_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Future<String> getDownloadPath() async {
} else {
directory = await getDownloadsDirectory();
}
} catch (err, stack) {
} catch (err) {
print("Cannot get download folder path");
}
return directory!.path;
Expand Down
16 changes: 11 additions & 5 deletions lib/views/widgets/Links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,33 @@ class Links extends StatelessWidget {
fontSize: fontSize,
)),
onTap: () async {
launch(url);
// parse url string and convert to Uri
try {
var uri = Uri.parse(url);
launchUrl(uri);
} catch (e) {
print("Failed to parse url: $e");
}
},
);
}

return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
getLink(FEEDBACK, FEEDBACK_LINK),
getLink(FEEDBACK, feedbackLink),
SizedBox(
width: 24.0,
),
getLink(FAQ, FAQ_LINK),
getLink(FAQ, fagLink),
SizedBox(
width: 24.0,
),
getLink(PRIVACY, PRIVACY_LINK),
getLink(PRIVACY, privacyLink),
SizedBox(
width: 24.0,
),
getLink(TERMS, TERMS_LINK),
getLink(TERMS, termsLink),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/CodeInputBox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CodeInputBox extends StatelessWidget {
required this.style,
required this.codeChanged,
required this.width,
required final this.controller,
required this.controller,
required this.onEnterPressed})
: super(key: key);
@override
Expand Down
13 changes: 6 additions & 7 deletions lib/widgets/buttons/Button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class Button extends StatelessWidget {
String? title;
Function handleSelectFile;
Widget? icon;
bool? disabled;
double? width;
double? height;
Color? bgColor;
final String? title;
final Function handleSelectFile;
final bool? disabled;
final double? width;
final double? height;
final Color? bgColor;

Button(this.title, this.handleSelectFile, this.disabled, this.height,
this.width, this.bgColor);
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ String? uriStringValidator(String? value) {
if (!allowedSchemes.contains(uri.scheme)) {
return "<scheme> should be one of ${allowedSchemes.join(", ")}";
}
return null;
}
14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
Expand Down Expand Up @@ -385,6 +392,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.7.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
logging:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dev_dependencies:
build_runner: ^2.2.1
crypto: ^3.0.1
msix: ^3.6.2
flutter_lints: ^2.0.1

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
4 changes: 0 additions & 4 deletions test/widgets/prefs_edit_test.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import 'dart:ui';

import 'package:destiny/config/theme/custom_theme.dart';
import 'package:destiny/widgets/prefs_edit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:streaming_shared_preferences/streaming_shared_preferences.dart';
Expand Down