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:
|
code_analyze:
|
||||||
stage: coverage
|
stage: coverage
|
||||||
script: [./scripts/code_analyze.sh]
|
script: [./scripts/code_analyze.sh]
|
||||||
|
artifacts:
|
||||||
|
reports:
|
||||||
|
codequality: code-quality-report.json
|
||||||
|
|
||||||
code_analyze_beta:
|
code_analyze_beta:
|
||||||
extends: code_analyze
|
extends: code_analyze
|
||||||
|
@ -15,3 +15,37 @@ analyzer:
|
|||||||
exclude:
|
exclude:
|
||||||
- lib/generated_plugin_registrant.dart
|
- lib/generated_plugin_registrant.dart
|
||||||
- lib/l10n/*.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 scrollDown() => scrollController.jumpTo(0);
|
||||||
|
|
||||||
void onEmojiSelected(category, emoji) {
|
void onEmojiSelected(_, emoji) {
|
||||||
setState(() => showEmojiPicker = false);
|
setState(() => showEmojiPicker = false);
|
||||||
if (emoji == null) return;
|
if (emoji == null) return;
|
||||||
// make sure we don't send the same emoji twice
|
// make sure we don't send the same emoji twice
|
||||||
@ -721,7 +721,7 @@ class ChatController extends State<Chat> {
|
|||||||
return index + 1;
|
return index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void onInputBarSubmitted(String text) {
|
void onInputBarSubmitted(_) {
|
||||||
send();
|
send();
|
||||||
FocusScope.of(context).requestFocus(inputFocus);
|
FocusScope.of(context).requestFocus(inputFocus);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
if (token != null) _loginWithToken(token);
|
if (token != null) _loginWithToken(token);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
checkHomeserverAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -104,7 +105,7 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
/// makes sure that it is prefixed with https. Then it searches for the
|
/// 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
|
/// well-known information and forwards to the login page depending on the
|
||||||
/// login type.
|
/// login type.
|
||||||
void checkHomeserverAction() async {
|
Future<void> checkHomeserverAction() async {
|
||||||
_coolDown?.cancel();
|
_coolDown?.cancel();
|
||||||
try {
|
try {
|
||||||
if (domain.isEmpty) throw L10n.of(context).changeTheHomeserver;
|
if (domain.isEmpty) throw L10n.of(context).changeTheHomeserver;
|
||||||
@ -220,15 +221,9 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||||||
|
|
||||||
void signUpAction() => VRouter.of(context).to('signup');
|
void signUpAction() => VRouter.of(context).to('signup');
|
||||||
|
|
||||||
bool _initialized = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Matrix.of(context).navigatorContext = context;
|
Matrix.of(context).navigatorContext = context;
|
||||||
if (!_initialized) {
|
|
||||||
_initialized = true;
|
|
||||||
checkHomeserverAction();
|
|
||||||
}
|
|
||||||
return HomeserverPickerView(this);
|
return HomeserverPickerView(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||||||
final _audioRecorder = Record();
|
final _audioRecorder = Record();
|
||||||
Amplitude _amplitude;
|
Amplitude _amplitude;
|
||||||
|
|
||||||
void startRecording() async {
|
Future<void> startRecording() async {
|
||||||
try {
|
try {
|
||||||
final tempDir = await getTemporaryDirectory();
|
final tempDir = await getTemporaryDirectory();
|
||||||
_recordedPath =
|
_recordedPath =
|
||||||
|
@ -124,7 +124,7 @@ class SearchController extends State<Search> {
|
|||||||
'user_id': text,
|
'user_id': text,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
setState(() {});
|
setState(() => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _init = false;
|
bool _init = false;
|
||||||
|
@ -63,8 +63,9 @@ class SearchView extends StatelessWidget {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(controller.controller.text.toLowerCase()),
|
.contains(controller.controller.text.toLowerCase()),
|
||||||
);
|
);
|
||||||
|
const tabCount = 3;
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
length: 3,
|
length: tabCount,
|
||||||
initialIndex:
|
initialIndex:
|
||||||
controller.controller.text?.startsWith('#') ?? false ? 0 : 1,
|
controller.controller.text?.startsWith('#') ?? false ? 0 : 1,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@ -171,7 +172,8 @@ class SearchView extends StatelessWidget {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(12),
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate:
|
||||||
|
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
childAspectRatio: 1,
|
childAspectRatio: 1,
|
||||||
crossAxisSpacing: 16,
|
crossAxisSpacing: 16,
|
||||||
|
@ -105,13 +105,9 @@ class BackgroundPush {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> fullInit() async {
|
Future<void> fullInit() => setupPush();
|
||||||
await setupPush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleLoginStateChanged(LoginState state) {
|
void handleLoginStateChanged(_) => setupPush();
|
||||||
setupPush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _newFcmToken(String token) {
|
void _newFcmToken(String token) {
|
||||||
_fcmToken = token;
|
_fcmToken = token;
|
||||||
|
@ -6,8 +6,10 @@ import 'package:native_imaging/native_imaging.dart' as native;
|
|||||||
|
|
||||||
import 'run_in_background.dart';
|
import 'run_in_background.dart';
|
||||||
|
|
||||||
|
const int defaultMax = 800;
|
||||||
|
|
||||||
Future<MatrixImageFile> resizeImage(MatrixImageFile file,
|
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
|
// we want to resize the image in a separate isolate, because otherwise that can
|
||||||
// freeze up the UI a bit
|
// freeze up the UI a bit
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// ignore: camel_case_types
|
// ignore: camel_case_types
|
||||||
class platformViewRegistry {
|
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());
|
launch(uri.replace(host: newHost).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void openMatrixToUrl([bool startDirectChat = false]) async {
|
void openMatrixToUrl() async {
|
||||||
final matrix = Matrix.of(context);
|
final matrix = Matrix.of(context);
|
||||||
// The identifier might be a matrix.to url and needs escaping. Or, it might have multiple
|
// 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.
|
// identifiers (room id & event id), or it might also have a query part.
|
||||||
|
@ -113,8 +113,7 @@ class _ImageBubbleState extends State<ImageBubble> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget frameBuilder(
|
Widget frameBuilder(_, Widget child, int frame, __) {
|
||||||
BuildContext context, Widget child, int frame, bool sync) {
|
|
||||||
// as servers might return animated gifs as thumbnails and we want them to *not* play
|
// 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
|
// animated, we'll have to store the first frame in a variable and display that instead
|
||||||
if (widget.animated) {
|
if (widget.animated) {
|
||||||
@ -249,7 +248,8 @@ class _ImageBubbleState extends State<ImageBubble> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (blurhash != null) blurhash,
|
if (blurhash != null) blurhash,
|
||||||
Center(
|
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(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('/' + command, style: const TextStyle(fontFamily: 'monospace')),
|
Text('/' + command,
|
||||||
|
style: const TextStyle(fontFamily: 'monospace')),
|
||||||
Text(_commandHint(L10n.of(context), command),
|
Text(_commandHint(L10n.of(context), command),
|
||||||
style: Theme.of(context).textTheme.caption),
|
style: Theme.of(context).textTheme.caption),
|
||||||
],
|
],
|
||||||
@ -291,7 +292,7 @@ class InputBar extends StatelessWidget {
|
|||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertSuggestion(BuildContext context, Map<String, String> suggestion) {
|
void insertSuggestion(_, Map<String, String> suggestion) {
|
||||||
final replaceText =
|
final replaceText =
|
||||||
controller.text.substring(0, controller.selection.baseOffset);
|
controller.text.substring(0, controller.selection.baseOffset);
|
||||||
var startText = '';
|
var startText = '';
|
||||||
|
32
pubspec.lock
32
pubspec.lock
@ -7,7 +7,7 @@ packages:
|
|||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "21.0.0"
|
version: "29.0.0"
|
||||||
adaptive_dialog:
|
adaptive_dialog:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -28,7 +28,14 @@ packages:
|
|||||||
name: analyzer
|
name: analyzer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
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:
|
animations:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -36,6 +43,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
|
ansicolor:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: ansicolor
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
archive:
|
archive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -197,6 +211,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.6.0"
|
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:
|
dbus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -74,6 +74,7 @@ dependencies:
|
|||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
dapackages: ^1.6.0
|
dapackages: ^1.6.0
|
||||||
|
dart_code_metrics: ^4.2.0-dev.3
|
||||||
flutter_lints: ^1.0.4
|
flutter_lints: ^1.0.4
|
||||||
flutter_native_splash: ^1.2.4
|
flutter_native_splash: ^1.2.4
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -2,3 +2,4 @@
|
|||||||
git apply ./scripts/enable-android-google-services.patch
|
git apply ./scripts/enable-android-google-services.patch
|
||||||
flutter format lib/ test/ --set-exit-if-changed
|
flutter format lib/ test/ --set-exit-if-changed
|
||||||
flutter analyze
|
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