Skip to content

Commit f157394

Browse files
Clean up abstract classes that only contain static methods (#9170)
* Clean up abstract classes that only contain static methods * remove unused parameter
1 parent ca2cdfb commit f157394

28 files changed

+65
-81
lines changed

packages/devtools_app/lib/src/framework/framework_core.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ typedef ErrorReporter = void Function(String title, Object error);
4444

4545
final _log = Logger('framework_core');
4646

47-
// ignore: avoid_classes_with_only_static_members, intentional grouping of static methods.
48-
abstract class FrameworkCore {
47+
/// A namespace for core framework objects and methods.
48+
extension FrameworkCore on Never {
4949
static final _memoryObserver = MemoryObserver();
5050

5151
/// Initializes the DevTools framework, which includes setting up global

packages/devtools_app/lib/src/screens/debugger/debugger_model.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ class StackFrameAndSourcePosition {
236236
}
237237
}
238238

239-
// ignore: avoid_classes_with_only_static_members, fine for utility method.
240-
abstract class ScriptRefUtils {
239+
/// A namespace for [ScriptRef] utilities.
240+
extension ScriptRefUtils on Never {
241241
static String fileName(ScriptRef scriptRef) =>
242242
fileNameFromUri(Uri.parse(scriptRef.uri!).path)!;
243243
}

packages/devtools_app/lib/src/screens/debugger/span_parser.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'package:collection/collection.dart';
99
import 'package:string_scanner/string_scanner.dart';
1010

1111
//TODO(jacobr): cleanup.
12-
// ignore: avoid_classes_with_only_static_members
13-
abstract class SpanParser {
12+
/// A namespace for [SpanParser] utilities.
13+
extension SpanParser on Never {
1414
/// Takes a TextMate [Grammar] and a [String] and outputs a list of
1515
/// [ScopeSpan]s corresponding to the parsed input.
1616
static List<ScopeSpan> parse(Grammar grammar, String src) {

packages/devtools_app/lib/src/screens/memory/panes/chart/controller/charts/android_chart_controller.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import '../../../../../../shared/charts/chart_trace.dart'
1313
import '../../../../shared/primitives/memory_timeline.dart';
1414
import '../../data/charts.dart';
1515

16-
// ignore: avoid_classes_with_only_static_members, enum-like classes are ok
17-
class _Color {
16+
/// A namespace for Android memory chart color constants.
17+
extension _Color on Never {
1818
static const otherColor = Color(0xffff8800); // HoloOrangeDark;
1919
static const nativeHeapColor = Color(0xff33b5e5); // HoloBlueLight
2020
static final graphicColor = Colors.greenAccent.shade400;

packages/devtools_app/lib/src/screens/memory/panes/chart/controller/charts/vm_chart_controller.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import '../../../../../../shared/charts/chart_trace.dart'
1313
import '../../../../shared/primitives/memory_timeline.dart';
1414
import '../../data/charts.dart';
1515

16-
// ignore: avoid_classes_with_only_static_members, enum-like classes are ok
17-
class _Colors {
16+
/// A namespace for VM memory chart color constants.
17+
extension _Colors on Never {
1818
static final capacity = Colors.grey[400]!;
1919
static const used = Color(0xff33b5e5);
2020
static const externals = Color(0xff4ddeff);

packages/devtools_app/lib/src/shared/analytics/constants/_property_editor_sidebar_constants.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
part of '../constants.dart';
66

7-
// ignore: avoid_classes_with_only_static_members, used for namespacing.
8-
class PropertyEditorSidebar {
7+
/// A namespace for Property Editor analytics.
8+
extension PropertyEditorSidebar on Never {
99
/// Analytics id to track events that come from the DTD editor sidebar.
1010
static String get id => 'propertyEditorSidebar';
1111

packages/devtools_app/lib/src/shared/analytics/gtags.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import 'analytics.dart' as ga;
2121
external void _gTagCommandName(String command, String name, [JSObject? params]);
2222

2323
// TODO(jacobr): refactor this code if we do not migrate off gtags.
24-
// ignore: avoid_classes_with_only_static_members
25-
class GTag {
24+
/// A namespace for gtags.
25+
extension GTag on Never {
2626
static const _event = 'event';
2727
static const _exception = 'exception';
2828

packages/devtools_app/lib/src/shared/charts/flame_chart.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,8 @@ extension NodeListExtension on List<FlameChartNode> {
889889
}
890890
}
891891

892-
// TODO(jacobr): cleanup up this util class with just static members.
893-
// ignore: avoid_classes_with_only_static_members
894-
class FlameChartUtils {
892+
/// A namespace for flame chart utilities.
893+
extension FlameChartUtils on Never {
895894
static double leftPaddingForNode(
896895
int index,
897896
List<FlameChartNode> nodes, {

packages/devtools_app/lib/src/shared/development_helpers.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ void resetDevToolsExtensionEnabledStates() =>
8484
/// server connection.
8585
final stubExtensionEnabledStates = <String, ExtensionEnabledState>{};
8686

87-
// ignore: avoid_classes_with_only_static_members, useful for testing.
88-
abstract class StubDevToolsExtensions {
87+
/// A namespace for stubbed DevTools extensions.
88+
///
89+
/// These are useful for testing and local development.
90+
extension StubDevToolsExtensions on Never {
8991
/// Extension for package:foo detected from a running app that requires a
9092
/// connected app.
9193
static final fooExtension = DevToolsExtensionConfig.parse({

packages/devtools_app/lib/src/shared/feature_flags.dart

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ const _kNetworkDisconnectExperience = bool.fromEnvironment(
4141
defaultValue: true,
4242
);
4343

44-
// It is ok to have enum-like static only classes.
45-
// ignore: avoid_classes_with_only_static_members
46-
/// Flags to hide features under construction.
44+
/// A namespace for feature flags, which set the visibility of features under
45+
/// active development.
4746
///
4847
/// When adding a new feature flag, the developer is responsible for adding it
4948
/// to the [_allFlags] map for debugging purposes.
50-
abstract class FeatureFlags {
49+
extension FeatureFlags on Never {
5150
/// Flag to enable the DevTools memory observer, which attempts to help users
5251
/// avoid OOM crashes.
5352
///

packages/devtools_app/lib/src/shared/http/_http_date.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
part of 'http.dart';
1616

17-
// TODO(jacobr): cleanup this class with only static members.
18-
// ignore: avoid_classes_with_only_static_members
19-
/// Utility functions for working with dates with HTTP specific date formats.
20-
class HttpDate {
17+
/// A namespace for HTTP date utilities.
18+
extension HttpDate on Never {
2119
// Parse a cookie date string.
2220
static DateTime _parseCookieDate(String date) {
2321
const monthsLowerCase = const <String>[

packages/devtools_app/lib/src/shared/primitives/diagnostics_text_styles.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import 'package:devtools_app_shared/ui.dart';
66
import 'package:flutter/material.dart';
77

8-
// Enum-like static classes are ok.
9-
// ignore: avoid_classes_with_only_static_members
10-
class DiagnosticsTextStyles {
8+
/// A namespace for diagnostic text styles and utilities.
9+
extension DiagnosticsTextStyles on Never {
1110
static TextStyle unimportant(ColorScheme colorScheme) => TextStyle(
1211
color: colorScheme.isLight ? Colors.grey.shade500 : Colors.grey.shade600,
1312
);

packages/devtools_app/lib/src/shared/utils/utils.dart

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:flutter/widgets.dart';
1818
import 'package:logging/logging.dart';
1919
import 'package:vm_service/vm_service.dart';
2020

21+
// ignore: avoid-importing-entrypoint-exports, required to access version.
2122
import '../../../devtools.dart' as devtools;
2223
import '../../service/connected_app/connected_app.dart';
2324
import '../framework/app_error_handling.dart';

packages/devtools_app/test/screens/memory/tracing/tracing_pane_controller_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import 'package:devtools_app/src/screens/memory/panes/tracing/tracing_pane_contr
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:vm_service/vm_service.dart';
99

10-
// ignore: avoid_classes_with_only_static_members, ok for enum-like class
11-
class _Tests {
10+
/// A namespace for memory tracing tests.
11+
extension _Tests on Never {
1212
static final empty = TracePaneController(rootPackage: '');
1313

1414
static final selection = TracePaneController(

packages/devtools_app/test/test_infra/scenes/memory/default.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import '../scene_test_extensions.dart';
2727
// To run:
2828
// flutter run -t test/test_infra/scenes/memory/default.stager_app.g.dart -d macos
2929

30-
// ignore: avoid_classes_with_only_static_members, enum like classes are ok
31-
abstract class MemoryDefaultSceneHeaps {
30+
/// A namespace for stubbed data used in memory tests.
31+
extension MemoryDefaultSceneHeaps on Never {
3232
/// Many instances of the same class with different long paths.
3333
///
3434
/// If sorted by retaining path this class will be the second from the top.

packages/devtools_app/test/test_infra/test_data/performance/sample_performance_data.dart

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
// This is the Perfetto data from [samplePerformanceData] as data class objects.
66

7-
// ignore_for_file: avoid_classes_with_only_static_members
8-
97
import 'dart:convert';
108

119
import 'package:devtools_app/devtools_app.dart';
@@ -129,7 +127,7 @@ final timelineEventWithShaderJank = testTimelineEvent(
129127
);
130128

131129
/// Data for Frame (id: 2)
132-
abstract class FlutterFrame2 {
130+
extension FlutterFrame2 on Never {
133131
static final frame =
134132
FlutterFrame.fromJson({
135133
'number': 2,
@@ -364,7 +362,7 @@ abstract class FlutterFrame2 {
364362
}
365363

366364
/// Data for Frame (id: 4)
367-
abstract class FlutterFrame4 {
365+
extension FlutterFrame4 on Never {
368366
static final frame = FlutterFrame.fromJson(_frameJson)
369367
..setEventFlow(uiEvent)
370368
..setEventFlow(rasterEvent);
@@ -929,7 +927,7 @@ abstract class FlutterFrame4 {
929927
}
930928

931929
/// Data for Frame (id: 6)
932-
abstract class FlutterFrame6 {
930+
extension FlutterFrame6 on Never {
933931
static final frame = FlutterFrame.fromJson(_frameJson)
934932
..setEventFlow(uiEvent)
935933
..setEventFlow(rasterEvent);

packages/devtools_shared/lib/src/server/file_system.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'package:path/path.dart' as path;
99

1010
import 'devtools_store.dart';
1111

12-
// ignore: avoid_classes_with_only_static_members, requires refactor.
13-
class LocalFileSystem {
12+
/// A namespace local file system utlities.
13+
extension LocalFileSystem on Never {
1414
static String _userHomeDir() {
1515
final envKey = Platform.operatingSystem == 'windows' ? 'APPDATA' : 'HOME';
1616
return Platform.environment[envKey] ?? '.';

packages/devtools_shared/lib/src/server/handlers/_app_size.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _AppSizeHandler {
7+
/// A namespace for app size server request handlers.
8+
extension _AppSizeHandler on Never {
109
static shelf.Response getBaseAppSizeFile(
1110
ServerApi api,
1211
Map<String, String> queryParams,

packages/devtools_shared/lib/src/server/handlers/_deeplink.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _DeeplinkApiHandler {
7+
/// A namespace for deep link server request handlers.
8+
extension _DeeplinkApiHandler on Never {
109
static Future<shelf.Response> handleAndroidBuildVariants(
1110
ServerApi api,
1211
Map<String, String> queryParams,

packages/devtools_shared/lib/src/server/handlers/_devtools_extensions.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _ExtensionsApiHandler {
7+
/// A namespace for DevTools extensions server request handlers.
8+
extension _ExtensionsApiHandler on Never {
109
static Future<shelf.Response> handleServeAvailableExtensions(
1110
ServerApi api,
1211
Map<String, String> queryParams,

packages/devtools_shared/lib/src/server/handlers/_dtd.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _DtdApiHandler {
7+
/// A namespace for Dart Tooling Daemon (DTD) server request handlers.
8+
extension _DtdApiHandler on Never {
109
static shelf.Response handleGetDtdUri(
1110
ServerApi api,
1211
DtdInfo? dtd,

packages/devtools_shared/lib/src/server/handlers/_preferences.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _PreferencesApiHandler {
7+
/// A namespace for preferences server request handlers.
8+
extension _PreferencesApiHandler on Never {
109
static shelf.Response getPreferenceValue<T>(
1110
ServerApi api,
1211
Map<String, String> queryParams,

packages/devtools_shared/lib/src/server/handlers/_release_notes.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _ReleaseNotesHandler {
7+
/// A namespace for release notes server request handlers.
8+
extension _ReleaseNotesHandler on Never {
109
static shelf.Response getLastReleaseNotesVersion(
1110
ServerApi api,
1211
DevToolsUsage devToolsStore,

packages/devtools_shared/lib/src/server/handlers/_storage.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _StorageHandler {
7+
/// A namespace for local storage request handlers.
8+
extension _StorageHandler on Never {
109
static shelf.Response handleGetStorageValue<T>(
1110
ServerApi api,
1211
DevToolsUsage devToolsStore, {

packages/devtools_shared/lib/src/server/handlers/_survey.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

9-
abstract class _SurveyHandler {
7+
/// A namespace for DevTools survey server request handlers.
8+
extension _SurveyHandler on Never {
109
static shelf.Response setActiveSurvey(
1110
ServerApi api,
1211
Map<String, String> queryParams,

packages/devtools_shared/lib/src/server/handlers/_general.dart renamed to packages/devtools_shared/lib/src/server/handlers/_vm_service.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5-
// ignore_for_file: avoid_classes_with_only_static_members
6-
75
part of '../server_api.dart';
86

7+
/// A namespace for VM service related server request handlers.
98
@visibleForTesting
10-
abstract class Handler {
9+
extension VmServiceHandler on Never {
1110
/// Stores the calculated package roots for VM service connections that are
1211
/// initiated in [handleNotifyForVmServiceConnection].
1312
///
@@ -68,7 +67,6 @@ abstract class Handler {
6867
vmServiceUriAsString: vmServiceUriAsString,
6968
vmServiceUri: vmServiceUri,
7069
connected: connected,
71-
api: api,
7270
dtd: dartToolingDaemon,
7371
);
7472
if (detectRootResponse.success) {
@@ -98,7 +96,6 @@ abstract class Handler {
9896
required String vmServiceUriAsString,
9997
required Uri vmServiceUri,
10098
required bool connected,
101-
required ServerApi api,
10299
required DartToolingDaemon dtd,
103100
}) async {
104101
final Uri rootPackageUri;

packages/devtools_shared/lib/src/server/server_api.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ part 'handlers/_app_size.dart';
3232
part 'handlers/_deeplink.dart';
3333
part 'handlers/_devtools_extensions.dart';
3434
part 'handlers/_dtd.dart';
35-
part 'handlers/_general.dart';
35+
part 'handlers/_vm_service.dart';
3636
part 'handlers/_preferences.dart';
3737
part 'handlers/_release_notes.dart';
3838
part 'handlers/_storage.dart';
@@ -64,7 +64,7 @@ class ServerApi {
6464
final queryParams = request.requestedUri.queryParameters;
6565
switch (request.url.path) {
6666
case apiNotifyForVmServiceConnection:
67-
return Handler.handleNotifyForVmServiceConnection(
67+
return VmServiceHandler.handleNotifyForVmServiceConnection(
6868
api,
6969
queryParams,
7070
dtd,

0 commit comments

Comments
 (0)