Skip to content

Commit 5e5c861

Browse files
authored
[CQ] Unnecessary code cleanup (#8080)
Addressed/removed unnecessary code in the form of: * redundant suppressions * redundant throws * redundant casts * unused imports * redundant `toString()`, `substring(..)` calls * unnecessary `default` branches * explicit types where `<>` will do * stream API call chains where `toList()` is enough ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
1 parent 00b4454 commit 5e5c861

File tree

13 files changed

+11
-18
lines changed

13 files changed

+11
-18
lines changed

flutter-idea/src/io/flutter/actions/FlutterBuildActionGroup.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ public void processTerminated(@NotNull ProcessEvent event) {
4747
};
4848
final Module module = pubRoot.getModule(project);
4949
if (module != null) {
50-
//noinspection ConstantConditions
5150
sdk.flutterBuild(pubRoot, buildType.type).startInModuleConsole(module, pubRoot::refresh, processAdapter);
5251
}
5352
else {
54-
//noinspection ConstantConditions
5553
final ColoredProcessHandler processHandler = sdk.flutterBuild(pubRoot, buildType.type).startInConsole(project);
5654
if (processHandler == null) {
5755
progressHelper.done();

flutter-idea/src/io/flutter/devtools/DevToolsUtils.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import org.dartlang.vm.service.VmServiceListener;
1616
import org.jetbrains.annotations.NotNull;
1717

18-
import org.dartlang.vm.service.element.Event;
19-
2018
import com.google.gson.JsonObject;
2119
import com.intellij.openapi.application.ApplicationManager;
2220
import com.intellij.openapi.vfs.LocalFileSystem;

flutter-idea/src/io/flutter/editor/ActiveEditorsOutlineService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public List<EditorEx> getActiveDartEditors() {
9595
for (FileEditor fileEditor : editors) {
9696
if (!(fileEditor instanceof TextEditor textEditor)) continue;
9797
final Editor editor = textEditor.getEditor();
98-
if (editor instanceof EditorEx && !editor.isDisposed() && FlutterUtils.isDartFile(((EditorEx)editor).getVirtualFile())) {
98+
if (editor instanceof EditorEx && !editor.isDisposed() && FlutterUtils.isDartFile(editor.getVirtualFile())) {
9999
dartEditors.add((EditorEx)editor);
100100
}
101101
}

flutter-idea/src/io/flutter/font/FontPreviewProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public void addClasses(@NotNull String packageName, @NotNull String filePath, @N
576576
classesToAnalyze.addAll(
577577
names.stream()
578578
.map((each) -> new ClassInfo(packageName, filePath, each))
579-
.collect(Collectors.toList()));
579+
.toList());
580580
}
581581

582582
void addFilesToRewrite(@NotNull String packageName, @NotNull Collection<VirtualFile> files) {
@@ -588,7 +588,7 @@ void addFilesToRewrite(@NotNull String packageName, @NotNull Collection<VirtualF
588588
return !(packageIndex < 0 || isInSdk(path));
589589
})
590590
.map((each) -> new FileInfo(packageName, each.getPath(), each))
591-
.collect(Collectors.toList()));
591+
.toList());
592592
}
593593
}
594594

flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public Logger logger() {
219219
case MISSING_PLATFORM_FILES -> "JX Browser platform files are missing";
220220
case CLASS_LOAD_FAILED -> "JX Browser class load failed";
221221
case CLASS_NOT_FOUND -> "JX Browser class not found";
222-
default -> null;
223222
};
224223

225224
}

flutter-idea/src/io/flutter/run/FlutterConfigurationEditorForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected void resetEditorFrom(@NotNull final SdkRunConfig config) {
4343
}
4444

4545
@Override
46-
protected void applyEditorTo(@NotNull final SdkRunConfig config) throws ConfigurationException {
46+
protected void applyEditorTo(@NotNull final SdkRunConfig config) {
4747
final SdkFields fields = new SdkFields();
4848
fields.setFilePath(StringUtil.nullize(FileUtil.toSystemIndependentName(myFileField.getText().trim()), true));
4949
fields.setBuildFlavor(StringUtil.nullize(myBuildFlavorField.getText().trim()));

flutter-idea/src/io/flutter/run/FlutterReloadManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private void handleSaveAllNotification(@Nullable Editor editor) {
234234
if (file == null) {
235235
return;
236236
}
237-
if (file.getPath().startsWith(configPath.toString())) {
237+
if (file.getPath().startsWith(configPath)) {
238238
return; // Ignore changes to scratch files.
239239
}
240240
if (System.currentTimeMillis() - file.getTimeStamp() > 500) {

flutter-idea/src/io/flutter/run/bazel/FlutterBazelConfigurationEditorForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected void resetEditorFrom(@NotNull final BazelRunConfig configuration) {
4343
}
4444

4545
@Override
46-
protected void applyEditorTo(@NotNull final BazelRunConfig configuration) throws ConfigurationException {
46+
protected void applyEditorTo(@NotNull final BazelRunConfig configuration) {
4747
String target = myTarget.getText().trim();
4848
final BazelFields fields = new BazelFields(
4949
StringUtil.nullize(target.endsWith("dart") ? FileUtil.toSystemIndependentName(target) : target, true),

flutter-idea/src/io/flutter/run/coverage/FlutterCoverageProgramRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public RunnerSettings createConfigurationData(@NotNull final ConfigurationInfoPr
6262
@Override
6363
@Nullable
6464
protected RunContentDescriptor doExecute(final @NotNull RunProfileState state,
65-
final @NotNull ExecutionEnvironment env) throws ExecutionException {
65+
final @NotNull ExecutionEnvironment env) {
6666
final RunContentDescriptor result = DefaultProgramRunnerKt.executeState(state, env, this);
6767
if (result == null) {
6868
return null;

flutter-idea/src/io/flutter/run/test/TestForm.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.intellij.openapi.options.ConfigurationException;
1010
import com.intellij.openapi.options.SettingsEditor;
1111
import com.intellij.openapi.project.Project;
12-
import com.intellij.openapi.ui.TextComponentAccessor;
1312
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
1413
import com.intellij.ui.ListCellRendererWrapper;
1514
import io.flutter.run.test.TestFields.Scope;
@@ -96,12 +95,11 @@ protected void resetEditorFrom(@NotNull TestConfig config) {
9695
}
9796

9897
@Override
99-
protected void applyEditorTo(@NotNull TestConfig config) throws ConfigurationException {
98+
protected void applyEditorTo(@NotNull TestConfig config) {
10099
final TestFields fields = switch (getScope()) {
101100
case NAME -> TestFields.forTestName(testName.getText(), testFile.getText());
102101
case FILE -> TestFields.forFile(testFile.getText());
103102
case DIRECTORY -> TestFields.forDir(testDir.getText());
104-
default -> throw new ConfigurationException("unexpected scope: " + scope.getSelectedItem());
105103
};
106104
fields.setAdditionalArgs(additionalArgs.getText().trim());
107105
config.setFields(fields);

0 commit comments

Comments
 (0)