Skip to content

Commit

Permalink
Update dependencies and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ThexXTURBOXx committed Feb 10, 2024
1 parent 157526d commit c303b67
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 175 deletions.
81 changes: 52 additions & 29 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ analyzer:
# allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
sdk_version_async_exported_from_core: ignore
# Ignore imports due to f***ed up import hierarchies.
unnecessary_import: ignore
exclude:
Expand All @@ -32,11 +28,15 @@ analyzer:
# see https://github.com/dart-lang/sdk/issues/28463
- "lib/i18n/messages_*.dart"
- "lib/src/http/**"
# Ignore generated icons
- "lib/icons/studi_passau_icons.dart"
# Ignore generated localizations
- "lib/generated/l10n.dart"
- "lib/generated/intl/messages_*.dart"
# Ignore generated plugin registrant
- "lib/generated_plugin_registrant.dart"
# Ignore ugly env-related files
- "lib/env/**"

linter:
# The lint rules applied to this project can be customized in the
Expand All @@ -51,36 +51,35 @@ linter:
# `// 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
always_declare_return_types: true
always_put_control_body_on_new_line: true
# always_put_required_named_parameters_first: true
always_put_required_named_parameters_first: true
always_require_non_null_named_parameters: true
# always_specify_types: true
always_specify_types: false
always_use_package_imports: true
annotate_overrides: true
# avoid_annotating_with_dynamic: true
avoid_annotating_with_dynamic: true
avoid_bool_literals_in_conditional_expressions: true
# avoid_catches_without_on_clauses: true
avoid_catches_without_on_clauses: false
avoid_catching_errors: true
avoid_classes_with_only_static_members: true
avoid_double_and_int_checks: true
# avoid_dynamic_calls: true
avoid_dynamic_calls: false
avoid_empty_else: true
avoid_equals_and_hash_code_on_mutable_classes: true
avoid_escaping_inner_quotes: true
avoid_field_initializers_in_const_classes: true
avoid_final_parameters: true
avoid_function_literals_in_foreach_calls: true
# avoid_implementing_value_types: true
avoid_implementing_value_types: true
avoid_init_to_null: true
avoid_js_rounded_ints: true
avoid_multiple_declarations_per_line: true
avoid_null_checks_in_equality_operators: true
avoid_positional_boolean_parameters: true
avoid_print: true
avoid_private_typedef_functions: true
# avoid_redundant_argument_values: true
avoid_redundant_argument_values: false
avoid_relative_lib_imports: true
avoid_renaming_method_parameters: true
avoid_return_types_on_setters: true
Expand All @@ -103,17 +102,23 @@ linter:
camel_case_extensions: true
camel_case_types: true
cancel_subscriptions: true
# cascade_invocations: true
cascade_invocations: true
cast_nullable_to_non_nullable: true
close_sinks: true
collection_methods_unrelated_type: true
combinators_ordering: true
comment_references: true
conditional_uri_does_not_exist: true
constant_identifier_names: true
control_flow_in_finally: true
curly_braces_in_flow_control_structures: true
dangling_library_doc_comments: true
depend_on_referenced_packages: true
deprecated_consistency: true
# diagnostic_describe_all_properties: true
deprecated_member_use_from_same_package: true
diagnostic_describe_all_properties: true
directives_ordering: true
discarded_futures: false
do_not_use_environment: true
empty_catches: true
empty_constructor_bodies: true
Expand All @@ -124,23 +129,29 @@ linter:
flutter_style_todos: true
hash_and_equals: true
implementation_imports: true
iterable_contains_unrelated_type: true
implicit_call_tearoffs: true
implicit_reopen: true
invalid_case_patterns: true
join_return_with_assignment: true
leading_newlines_in_multiline_strings: true
library_annotations: true
library_names: true
library_prefixes: true
library_private_types_in_public_api: true
lines_longer_than_80_chars: true
list_remove_unrelated_type: true
literal_only_boolean_expressions: true
matching_super_parameters: true
missing_whitespace_between_adjacent_strings: true
no_adjacent_strings_in_list: true
# no_default_cases: true
no_default_cases: false
no_duplicate_case_values: true
no_leading_underscores_for_library_prefixes: true
no_leading_underscores_for_local_identifiers: true
no_literal_bool_comparisons: true
no_logic_in_create_state: true
no_runtimeType_toString: true
no_self_assignments: true
no_wildcard_variable_uses: true
non_constant_identifier_names: true
noop_primitive_operations: true
null_check_on_nullable_type_parameter: true
Expand All @@ -164,13 +175,12 @@ linter:
prefer_const_literals_to_create_immutables: true
prefer_constructors_over_static_methods: true
prefer_contains: true
# prefer_double_quotes: true
# prefer_equal_for_default_values: true
prefer_double_quotes: false
prefer_expression_function_bodies: true
prefer_final_fields: true
prefer_final_in_for_each: true
prefer_final_locals: true
# prefer_final_parameters: true
prefer_final_parameters: false
prefer_for_elements_to_map_fromIterable: true
prefer_foreach: true
prefer_function_declarations_over_variables: true
Expand All @@ -188,37 +198,43 @@ linter:
prefer_mixin: true
prefer_null_aware_method_calls: true
prefer_null_aware_operators: true
# prefer_relative_imports: true
prefer_relative_imports: false
prefer_single_quotes: true
prefer_spread_collections: true
prefer_typing_uninitialized_variables: true
prefer_void_to_null: true
provide_deprecation_message: true
# public_member_api_docs: true
public_member_api_docs: false
recursive_getters: true
require_trailing_commas: true
secure_pubspec_urls: true
sized_box_for_whitespace: true
sized_box_shrink_expand: true
slash_for_doc_comments: true
sort_child_properties_last: true
# sort_constructors_first: true
sort_constructors_first: true
sort_pub_dependencies: true
sort_unnamed_constructors_first: true
test_types_in_equals: true
throw_in_finally: true
tighten_type_of_initializing_formals: true
type_annotate_public_apis: true
type_annotate_public_apis: false
type_init_formals: true
type_literal_in_constant_pattern: true
unawaited_futures: true
unnecessary_await_in_return: true
unnecessary_brace_in_string_interps: true
unnecessary_breaks: true
unnecessary_const: true
unnecessary_constructor_name: true
# unnecessary_final: true
unnecessary_final: false
unnecessary_getters_setters: true
unnecessary_lambdas: true
unnecessary_late: true
unnecessary_library_directive: true
unnecessary_new: true
unnecessary_null_aware_assignments: true
unnecessary_null_aware_operator_on_extension_on_nullable: true
unnecessary_null_checks: true
unnecessary_null_in_if_null_operators: true
unnecessary_nullable_for_final_variable_declarations: true
Expand All @@ -229,9 +245,14 @@ linter:
unnecessary_string_escapes: true
unnecessary_string_interpolations: true
unnecessary_this: true
unnecessary_to_list_in_spreads: true
unreachable_from_main: true
unrelated_type_equality_checks: true
unsafe_html: true
use_build_context_synchronously: true
use_colored_box: true
use_decorated_box: true
use_enums: true
use_full_hex_values_for_flutter_colors: true
use_function_type_syntax_for_parameters: true
use_if_null_to_convert_nulls_to_bools: true
Expand All @@ -243,10 +264,12 @@ linter:
use_rethrow_when_possible: true
use_setters_to_change_properties: true
use_string_buffers: true
use_string_in_part_of_directives: true
use_super_parameters: true
use_test_throws_matchers: true
use_to_and_as_if_applicable: true
valid_regexps: true
void_checks: true
: true
# Additional information about this file can be found at: true
# https://dart.dev/guides/language/analysis-options: true

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
8 changes: 4 additions & 4 deletions lib/bloc/cubits/data_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'package:powasys_frontend/util/hex_color.dart';
import 'package:tuple/tuple.dart';

class DataCubit extends Cubit<DataState> {
final DataRepo _dataRepo;

DataCubit(this._dataRepo) : super(const DataState(DataFetchState.notFetched));

final DataRepo _dataRepo;

Future<void> fetchData({
required List<int> disabledPowadors,
required Trend currentTrend,
Expand Down Expand Up @@ -76,8 +76,8 @@ class DataCubit extends Cubit<DataState> {
final powaId = int.parse(entry['powadorId'].toString());
if (!disabledPowadors.contains(powaId)) {
final values = {
for (var t in Trend.values)
t: entry[t.id] == null ? null : t.parse(entry[t.id].toString())
for (final t in Trend.values)
t: entry[t.id] == null ? null : t.parse(entry[t.id].toString()),
};
final value = values[currentTrend]! as double;
minVal = value < minVal ? value : minVal;
Expand Down
22 changes: 10 additions & 12 deletions lib/bloc/cubits/export_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore_for_file: missing_whitespace_between_adjacent_strings
import 'dart:convert';
import 'dart:html';

Expand All @@ -11,11 +10,11 @@ import 'package:powasys_frontend/generated/l10n.dart';
import 'package:tuple/tuple.dart';

class ExportCubit extends Cubit<ExportState> {
final DataRepo _dataRepo;

ExportCubit(this._dataRepo)
: super(const ExportState(ExportGenState.notStarted));

final DataRepo _dataRepo;

Future<void> exportData(S s, DateTime start, DateTime end, int minDiv) async {
try {
emit(state.copyWith(state: ExportGenState.exporting));
Expand All @@ -30,16 +29,15 @@ class ExportCubit extends Cubit<ExportState> {
final time = DateTime.parse(e['time'].toString());
final powaId = int.parse(e['powadorId'].toString());
final values = {
for (var t in Trend.values)
t: e[t.id] == null ? null : t.parse(e[t.id].toString())
for (final t in Trend.values)
t: e[t.id] == null ? null : t.parse(e[t.id].toString()),
};
return Tuple3(time, powaId, values);
}).toList(growable: false);

data.sort((a, b) {
final comp = a.item1.compareTo(b.item1);
return comp != 0 ? comp : a.item2.compareTo(b.item2);
});
}).toList(growable: false)
..sort((a, b) {
final comp = a.item1.compareTo(b.item1);
return comp != 0 ? comp : a.item2.compareTo(b.item2);
});

if (data.isEmpty) {
emit(
Expand All @@ -66,7 +64,7 @@ class ExportCubit extends Cubit<ExportState> {
"${decimalFormatTwo.format(e.item3[Trend.netCurrent])};"
"${e.item3[Trend.netPower]};"
"${e.item3[Trend.temperature]}\n",
).join("")}';
).join()}';

emit(
state.copyWith(
Expand Down
42 changes: 21 additions & 21 deletions lib/bloc/states.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@ import 'package:powasys_frontend/data/trend.dart';
import 'package:tuple/tuple.dart';

class BlocState<State> {
final State state;
final dynamic ex;

const BlocState(
this.state, {
this.ex,
});

final State state;
final dynamic ex;
}

class DataState extends BlocState<DataFetchState> {
final double minVal;
final double maxVal;
final Map<int, Tuple2<String, Color>> powadors;
final Map<int, Tuple2<DateTime, Map<Trend, num>>> latest;
final Map<int, Map<Trend, num>> averages;
final Map<int, Map<Trend, num>> max;
final Map<int, List<FlSpot>> data;

const DataState(
super.state, {
super.ex,
Expand All @@ -36,9 +28,17 @@ class DataState extends BlocState<DataFetchState> {
this.data = const {},
});

final double minVal;
final double maxVal;
final Map<int, Tuple2<String, Color>> powadors;
final Map<int, Tuple2<DateTime, Map<Trend, num>>> latest;
final Map<int, Map<Trend, num>> averages;
final Map<int, Map<Trend, num>> max;
final Map<int, List<FlSpot>> data;

DataState copyWith({
DataFetchState? state,
dynamic ex,
ex,
double? minVal,
double? maxVal,
Map<int, Tuple2<String, Color>>? powadors,
Expand Down Expand Up @@ -66,27 +66,27 @@ enum DataFetchState {
fetchedData(finished: true),
fetchError(finished: true, errored: true);

final bool finished;
final bool errored;

const DataFetchState({
this.finished = false,
this.errored = false,
});

final bool finished;
final bool errored;
}

class ExportState extends BlocState<ExportGenState> {
final AnchorElement? toDownload;

const ExportState(
super.state, {
super.ex,
this.toDownload,
});

final AnchorElement? toDownload;

ExportState copyWith({
ExportGenState? state,
dynamic ex,
ex,
AnchorElement? toDownload,
}) =>
ExportState(
Expand All @@ -102,11 +102,11 @@ enum ExportGenState {
exported(finished: true),
exportError(finished: true, errored: true);

final bool finished;
final bool errored;

const ExportGenState({
this.finished = false,
this.errored = false,
});

final bool finished;
final bool errored;
}
Loading

0 comments on commit c303b67

Please sign in to comment.