refactor: Add code quality reports

This commit is contained in:
Krille Fear 2021-10-16 09:59:38 +02:00
commit 2f978c5098
17 changed files with 93 additions and 29 deletions

View file

@ -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);
}

View file

@ -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);
}
}

View file

@ -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 =

View file

@ -124,7 +124,7 @@ class SearchController extends State<Search> {
'user_id': text,
}));
}
setState(() {});
setState(() => null);
}
bool _init = false;

View file

@ -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,

View file

@ -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;

View file

@ -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

View file

@ -1,4 +1,4 @@
// ignore: camel_case_types
class platformViewRegistry {
static void registerViewFactory(String viewId, dynamic cb) {}
static void registerViewFactory(String _, dynamic __) {}
}

View file

@ -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.

View file

@ -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),
),
],
);

View file

@ -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 = '';