• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Camelcade / Perl5-IDEA / #525521571

04 Jun 2025 08:10AM UTC coverage: 82.32% (-0.03%) from 82.347%
#525521571

push

github

hurricup
Replace NPE with IllegalStateException in handler lookups

0 of 6 new or added lines in 5 files covered. (0.0%)

23 existing lines in 8 files now uncovered.

30843 of 37467 relevant lines covered (82.32%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/plugin/docker/src/main/java/com/perl5/lang/perl/idea/sdk/host/docker/PerlDockerHandler.java
1
/*
2
 * Copyright 2015-2024 Alexandr Evstigneev
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.perl5.lang.perl.idea.sdk.host.docker;
18

19
import com.intellij.execution.ExecutionException;
20
import com.intellij.execution.configurations.PathEnvironmentVariableUtil;
21
import com.intellij.openapi.application.ApplicationManager;
22
import com.intellij.openapi.diagnostic.Logger;
23
import com.intellij.openapi.options.UnnamedConfigurable;
24
import com.intellij.openapi.project.Project;
25
import com.intellij.openapi.ui.Messages;
26
import com.intellij.openapi.ui.messages.MessagesService;
27
import com.intellij.openapi.util.NlsActions.ActionText;
28
import com.intellij.util.ArrayUtil;
29
import com.perl5.PerlIcons;
30
import com.perl5.lang.perl.idea.sdk.PerlHandlerBean;
31
import com.perl5.lang.perl.idea.sdk.host.PerlHostHandler;
32
import com.perl5.lang.perl.idea.sdk.host.PerlHostWithFileSystemHandler;
33
import com.perl5.lang.perl.idea.sdk.host.os.PerlOsHandler;
34
import com.perl5.lang.perl.idea.sdk.host.os.PerlOsHandlers;
35
import org.jetbrains.annotations.NotNull;
36
import org.jetbrains.annotations.Nullable;
37
import org.jetbrains.annotations.TestOnly;
38

39
import javax.swing.*;
40
import java.util.List;
41

42
class PerlDockerHandler extends PerlHostWithFileSystemHandler<PerlDockerData, PerlDockerHandler> {
43
  private static final Logger LOG = Logger.getInstance(PerlDockerHandler.class);
1✔
44

45
  @SuppressWarnings("NonDefaultConstructor")
46
  public PerlDockerHandler(@NotNull PerlHandlerBean bean) {
47
    super(bean);
1✔
48
  }
1✔
49

50
  @Override
51
  protected @Nullable PerlDockerData createDataInteractively() {
52
    PerlDockerData hostData = createData();
×
53
    List<String> images;
54
    try {
55
      images = new PerlDockerAdapter(hostData).listImages();
×
56
    }
57
    catch (ExecutionException e) {
×
58
      showErrorDialog(e.getMessage());
×
59
      LOG.warn("Error listing docker images: " + e.getMessage());
×
60
      return null;
×
61
    }
×
62
    if (images.isEmpty()) {
×
63
      showErrorDialog(PerlDockerBundle.message("perl.host.handler.docker.error.list.images.empty"));
×
64
      return null;
×
65
    }
66
    String[] imagesArray = ArrayUtil.toStringArray(images);
×
67
    int[] resultIndex = new int[]{-1};
×
68
    ApplicationManager.getApplication().invokeAndWait(
×
69
      () -> resultIndex[0] = MessagesService.getInstance().showChooseDialog(
×
70
        null, null,
71
        PerlDockerBundle.message("perl.host.handler.docker.choose.distro.message"),
×
72
        PerlDockerBundle.message("perl.host.handler.docker.choose.distro.title"),
×
73
        imagesArray, imagesArray[0], null));
74
    int index = resultIndex[0];
×
75

76
    if (index < 0 || index >= imagesArray.length) {
×
77
      return null;
×
78
    }
79
    hostData.withImageName(images.get(index));
×
80
    return hostData;
×
81
  }
82

83
  private void showErrorDialog(@NotNull String message) {
84
    ApplicationManager.getApplication().invokeAndWait(() -> Messages.showErrorDialog(
×
85
      message,
86
      PerlDockerBundle.message("perl.host.handler.docker.error.list.images.title")
×
87
    ));
88
  }
×
89

90
  @Override
91
  public @NotNull @ActionText String getMenuItemTitle() {
92
    return PerlDockerBundle.message("perl.host.handler.docker.menu.title");
1✔
93
  }
94

95
  @Override
96
  public @NotNull String getShortName() {
97
    return PerlDockerBundle.message("perl.host.handler.docker.short.name");
1✔
98
  }
99

100
  @Override
101
  public boolean isApplicable() {
102
    return PathEnvironmentVariableUtil.findInPath(PerlDockerAdapter.DOCKER_EXECUTABLE) != null;
1✔
103
  }
104

105
  @Override
106
  public @Nullable PerlOsHandler getOsHandler() {
107
    return PerlOsHandlers.LINUX;
1✔
108
  }
109

110
  @Override
111
  public @NotNull PerlDockerData createData() {
112
    return new PerlDockerData(this);
1✔
113
  }
114

115
  @Override
116
  public @Nullable UnnamedConfigurable getSettingsConfigurable(@NotNull Project project) {
117
    return new PerlDockerProjectSettingsConfigurable(project);
×
118
  }
119

120
  @Override
121
  public @Nullable Icon getIcon() {
122
    return PerlIcons.DOCKER_ICON;
1✔
123
  }
124

125
  @TestOnly
126
  static @NotNull PerlDockerHandler getInstance() {
127
    for (PerlHostHandler<?, ?> handler : PerlHostHandler.all()) {
1✔
128
      if (handler instanceof PerlDockerHandler perlDockerHandler) {
1✔
129
        return perlDockerHandler;
1✔
130
      }
131
    }
1✔
NEW
132
    throw new IllegalStateException("PerlDockerHandler is not registered");
×
133
  }
134
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc