mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
refactor: Add code quality reports
This commit is contained in:
parent
5be5f518e6
commit
e879278186
@ -18,6 +18,9 @@ stages:
|
||||
code_analyze:
|
||||
stage: coverage
|
||||
script: [./scripts/code_analyze.sh]
|
||||
artifacts:
|
||||
reports:
|
||||
codequality: code-quality-report.json
|
||||
|
||||
code_analyze_beta:
|
||||
extends: code_analyze
|
||||
|
@ -15,3 +15,37 @@ analyzer:
|
||||
exclude:
|
||||
- lib/generated_plugin_registrant.dart
|
||||
- lib/l10n/*.dart
|
||||
|
||||
dart_code_metrics:
|
||||
metrics:
|
||||
cyclomatic-complexity: 20
|
||||
number-of-arguments: 4
|
||||
maximum-nesting-level: 5
|
||||
source-lines-of-code: 50
|
||||
maintainability-index: 40
|
||||
rules:
|
||||
- no-boolean-literal-compare
|
||||
- no-empty-block
|
||||
- prefer-conditional-expressions
|
||||
- no-equal-then-else
|
||||
- no-magic-number:
|
||||
severity: style
|
||||
- avoid-late-keyword:
|
||||
severity: style
|
||||
- avoid-non-null-assertion:
|
||||
severity: style
|
||||
- avoid-unused-parameters
|
||||
- binary-expression-operand-order
|
||||
- avoid-unnecessary-setstate
|
||||
- avoid-wrapping-in-padding
|
||||
- prefer-const-border-radius
|
||||
- prefer-single-widget-per-file:
|
||||
ignore-private-widgets: true
|
||||
- prefer-extracting-callbacks
|
||||
metrics-exclude:
|
||||
- test/**
|
||||
rules-exclude:
|
||||
- test/**
|
||||
anti-patterns:
|
||||
- long-method
|
||||
- long-parameter-list
|
||||
|
1
code-quality-report.json
Normal file
1
code-quality-report.json
Normal file
File diff suppressed because one or more lines are too long
@ -601,7 +601,7 @@ class ChatController extends State<Chat> {
|
||||
|
||||
void scrollDown() => scrollController.jumpTo(0);
|
||||
|
||||
void onEmojiSelected(category, emoji) {
|
||||
void onEmojiSelected(_, emoji) {
|
||||
setState(() => showEmojiPicker = false);
|
||||
if (emoji == null) return;
|
||||
// make sure we don't send the same emoji twice
|
||||
@ -721,7 +721,7 @@ class ChatController extends State<Chat> {
|
||||
return index + 1;
|
||||
}
|
||||
|
||||
void onInputBarSubmitted(String text) {
|
||||
void onInputBarSubmitted(_) {
|
||||
send();
|
||||
FocusScope.of(context).requestFocus(inputFocus);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
if (token != null) _loginWithToken(token);
|
||||
});
|
||||
}
|
||||
checkHomeserverAction();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -104,7 +105,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
/// makes sure that it is prefixed with https. Then it searches for the
|
||||
/// well-known information and forwards to the login page depending on the
|
||||
/// login type.
|
||||
void checkHomeserverAction() async {
|
||||
Future<void> checkHomeserverAction() async {
|
||||
_coolDown?.cancel();
|
||||
try {
|
||||
if (domain.isEmpty) throw L10n.of(context).changeTheHomeserver;
|
||||
@ -220,15 +221,9 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
|
||||
void signUpAction() => VRouter.of(context).to('signup');
|
||||
|
||||
bool _initialized = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Matrix.of(context).navigatorContext = context;
|
||||
if (!_initialized) {
|
||||
_initialized = true;
|
||||
checkHomeserverAction();
|
||||
}
|
||||
return HomeserverPickerView(this);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
||||
final _audioRecorder = Record();
|
||||
Amplitude _amplitude;
|
||||
|
||||
void startRecording() async {
|
||||
Future<void> startRecording() async {
|
||||
try {
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
_recordedPath =
|
||||
|
@ -124,7 +124,7 @@ class SearchController extends State<Search> {
|
||||
'user_id': text,
|
||||
}));
|
||||
}
|
||||
setState(() {});
|
||||
setState(() => null);
|
||||
}
|
||||
|
||||
bool _init = false;
|
||||
|
@ -63,8 +63,9 @@ class SearchView extends StatelessWidget {
|
||||
.toLowerCase()
|
||||
.contains(controller.controller.text.toLowerCase()),
|
||||
);
|
||||
const tabCount = 3;
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
length: tabCount,
|
||||
initialIndex:
|
||||
controller.controller.text?.startsWith('#') ?? false ? 0 : 1,
|
||||
child: Scaffold(
|
||||
@ -171,7 +172,8 @@ class SearchView extends StatelessWidget {
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.all(12),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 1,
|
||||
crossAxisSpacing: 16,
|
||||
|
@ -105,13 +105,9 @@ class BackgroundPush {
|
||||
return instance;
|
||||
}
|
||||
|
||||
Future<void> fullInit() async {
|
||||
await setupPush();
|
||||
}
|
||||
Future<void> fullInit() => setupPush();
|
||||
|
||||
void handleLoginStateChanged(LoginState state) {
|
||||
setupPush();
|
||||
}
|
||||
void handleLoginStateChanged(_) => setupPush();
|
||||
|
||||
void _newFcmToken(String token) {
|
||||
_fcmToken = token;
|
||||
|
@ -6,8 +6,10 @@ import 'package:native_imaging/native_imaging.dart' as native;
|
||||
|
||||
import 'run_in_background.dart';
|
||||
|
||||
const int defaultMax = 800;
|
||||
|
||||
Future<MatrixImageFile> resizeImage(MatrixImageFile file,
|
||||
{int max = 800}) async {
|
||||
{int max = defaultMax}) async {
|
||||
// we want to resize the image in a separate isolate, because otherwise that can
|
||||
// freeze up the UI a bit
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// ignore: camel_case_types
|
||||
class platformViewRegistry {
|
||||
static void registerViewFactory(String viewId, dynamic cb) {}
|
||||
static void registerViewFactory(String _, dynamic __) {}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class UrlLauncher {
|
||||
launch(uri.replace(host: newHost).toString());
|
||||
}
|
||||
|
||||
void openMatrixToUrl([bool startDirectChat = false]) async {
|
||||
void openMatrixToUrl() async {
|
||||
final matrix = Matrix.of(context);
|
||||
// The identifier might be a matrix.to url and needs escaping. Or, it might have multiple
|
||||
// identifiers (room id & event id), or it might also have a query part.
|
||||
|
@ -113,8 +113,7 @@ class _ImageBubbleState extends State<ImageBubble> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget frameBuilder(
|
||||
BuildContext context, Widget child, int frame, bool sync) {
|
||||
Widget frameBuilder(_, Widget child, int frame, __) {
|
||||
// as servers might return animated gifs as thumbnails and we want them to *not* play
|
||||
// animated, we'll have to store the first frame in a variable and display that instead
|
||||
if (widget.animated) {
|
||||
@ -249,7 +248,8 @@ class _ImageBubbleState extends State<ImageBubble> {
|
||||
children: <Widget>[
|
||||
if (blurhash != null) blurhash,
|
||||
Center(
|
||||
child: child ?? const CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
child:
|
||||
child ?? const CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
@ -221,7 +221,8 @@ class InputBar extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('/' + command, style: const TextStyle(fontFamily: 'monospace')),
|
||||
Text('/' + command,
|
||||
style: const TextStyle(fontFamily: 'monospace')),
|
||||
Text(_commandHint(L10n.of(context), command),
|
||||
style: Theme.of(context).textTheme.caption),
|
||||
],
|
||||
@ -291,7 +292,7 @@ class InputBar extends StatelessWidget {
|
||||
return Container();
|
||||
}
|
||||
|
||||
void insertSuggestion(BuildContext context, Map<String, String> suggestion) {
|
||||
void insertSuggestion(_, Map<String, String> suggestion) {
|
||||
final replaceText =
|
||||
controller.text.substring(0, controller.selection.baseOffset);
|
||||
var startText = '';
|
||||
|
32
pubspec.lock
32
pubspec.lock
@ -7,7 +7,7 @@ packages:
|
||||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "21.0.0"
|
||||
version: "29.0.0"
|
||||
adaptive_dialog:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -28,7 +28,14 @@ packages:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
version: "2.6.0"
|
||||
analyzer_plugin:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer_plugin
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.7.0"
|
||||
animations:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -36,6 +43,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
ansicolor:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ansicolor
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -197,6 +211,20 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.0"
|
||||
dart_code_metrics:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: dart_code_metrics
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.2.0-dev.3"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_style
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
dbus:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -74,6 +74,7 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
dapackages: ^1.6.0
|
||||
dart_code_metrics: ^4.2.0-dev.3
|
||||
flutter_lints: ^1.0.4
|
||||
flutter_native_splash: ^1.2.4
|
||||
flutter_test:
|
||||
|
@ -2,3 +2,4 @@
|
||||
git apply ./scripts/enable-android-google-services.patch
|
||||
flutter format lib/ test/ --set-exit-if-changed
|
||||
flutter analyze
|
||||
flutter pub run dart_code_metrics:metrics lib -r gitlab > code-quality-report.json || true
|
Loading…
Reference in New Issue
Block a user