1 | //////////////////////////////////////////////////////////////////////////////// | |
2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
3 | // Copyright (C) 2001-2021 the original author or authors. | |
4 | // | |
5 | // This library is free software; you can redistribute it and/or | |
6 | // modify it under the terms of the GNU Lesser General Public | |
7 | // License as published by the Free Software Foundation; either | |
8 | // version 2.1 of the License, or (at your option) any later version. | |
9 | // | |
10 | // This library is distributed in the hope that it will be useful, | |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | // Lesser General Public License for more details. | |
14 | // | |
15 | // You should have received a copy of the GNU Lesser General Public | |
16 | // License along with this library; if not, write to the Free Software | |
17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | //////////////////////////////////////////////////////////////////////////////// | |
19 | ||
20 | package com.puppycrawl.tools.checkstyle.checks.imports; | |
21 | ||
22 | import java.io.IOException; | |
23 | import java.io.InputStream; | |
24 | import java.net.MalformedURLException; | |
25 | import java.net.URI; | |
26 | import java.util.ArrayDeque; | |
27 | import java.util.Deque; | |
28 | import java.util.HashMap; | |
29 | import java.util.Map; | |
30 | ||
31 | import javax.xml.parsers.ParserConfigurationException; | |
32 | ||
33 | import org.xml.sax.Attributes; | |
34 | import org.xml.sax.InputSource; | |
35 | import org.xml.sax.SAXException; | |
36 | ||
37 | import com.puppycrawl.tools.checkstyle.XmlLoader; | |
38 | import com.puppycrawl.tools.checkstyle.api.CheckstyleException; | |
39 | ||
40 | /** | |
41 | * Responsible for loading the contents of an import control configuration file. | |
42 | */ | |
43 | public final class ImportControlLoader extends XmlLoader { | |
44 | ||
45 | /** The public ID for the configuration dtd. */ | |
46 | private static final String DTD_PUBLIC_ID_1_0 = | |
47 | "-//Puppy Crawl//DTD Import Control 1.0//EN"; | |
48 | ||
49 | /** The new public ID for version 1_0 of the configuration dtd. */ | |
50 | private static final String DTD_PUBLIC_CS_ID_1_0 = | |
51 | "-//Checkstyle//DTD ImportControl Configuration 1.0//EN"; | |
52 | ||
53 | /** The public ID for the configuration dtd. */ | |
54 | private static final String DTD_PUBLIC_ID_1_1 = | |
55 | "-//Puppy Crawl//DTD Import Control 1.1//EN"; | |
56 | ||
57 | /** The new public ID for version 1_1 of the configuration dtd. */ | |
58 | private static final String DTD_PUBLIC_CS_ID_1_1 = | |
59 | "-//Checkstyle//DTD ImportControl Configuration 1.1//EN"; | |
60 | ||
61 | /** The public ID for the configuration dtd. */ | |
62 | private static final String DTD_PUBLIC_ID_1_2 = | |
63 | "-//Puppy Crawl//DTD Import Control 1.2//EN"; | |
64 | ||
65 | /** The new public ID for version 1_2 of the configuration dtd. */ | |
66 | private static final String DTD_PUBLIC_CS_ID_1_2 = | |
67 | "-//Checkstyle//DTD ImportControl Configuration 1.2//EN"; | |
68 | ||
69 | /** The public ID for the configuration dtd. */ | |
70 | private static final String DTD_PUBLIC_ID_1_3 = | |
71 | "-//Puppy Crawl//DTD Import Control 1.3//EN"; | |
72 | ||
73 | /** The new public ID for version 1_3 of the configuration dtd. */ | |
74 | private static final String DTD_PUBLIC_CS_ID_1_3 = | |
75 | "-//Checkstyle//DTD ImportControl Configuration 1.3//EN"; | |
76 | ||
77 | /** The public ID for the configuration dtd. */ | |
78 | private static final String DTD_PUBLIC_ID_1_4 = | |
79 | "-//Puppy Crawl//DTD Import Control 1.4//EN"; | |
80 | ||
81 | /** The new public ID for version 1_4 of the configuration dtd. */ | |
82 | private static final String DTD_PUBLIC_CS_ID_1_4 = | |
83 | "-//Checkstyle//DTD ImportControl Configuration 1.4//EN"; | |
84 | ||
85 | /** The resource for the configuration dtd. */ | |
86 | private static final String DTD_RESOURCE_NAME_1_0 = | |
87 | "com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_0.dtd"; | |
88 | ||
89 | /** The resource for the configuration dtd. */ | |
90 | private static final String DTD_RESOURCE_NAME_1_1 = | |
91 | "com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_1.dtd"; | |
92 | ||
93 | /** The resource for the configuration dtd. */ | |
94 | private static final String DTD_RESOURCE_NAME_1_2 = | |
95 | "com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_2.dtd"; | |
96 | ||
97 | /** The resource for the configuration dtd. */ | |
98 | private static final String DTD_RESOURCE_NAME_1_3 = | |
99 | "com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_3.dtd"; | |
100 | ||
101 | /** The resource for the configuration dtd. */ | |
102 | private static final String DTD_RESOURCE_NAME_1_4 = | |
103 | "com/puppycrawl/tools/checkstyle/checks/imports/import_control_1_4.dtd"; | |
104 | ||
105 | /** The map to lookup the resource name by the id. */ | |
106 | private static final Map<String, String> DTD_RESOURCE_BY_ID = new HashMap<>(); | |
107 | ||
108 | /** Name for attribute 'pkg'. */ | |
109 | private static final String PKG_ATTRIBUTE_NAME = "pkg"; | |
110 | ||
111 | /** Name for attribute 'name'. */ | |
112 | private static final String NAME_ATTRIBUTE_NAME = "name"; | |
113 | ||
114 | /** Name for attribute 'strategyOnMismatch'. */ | |
115 | private static final String STRATEGY_ON_MISMATCH_ATTRIBUTE_NAME = "strategyOnMismatch"; | |
116 | ||
117 | /** Value "allowed" for attribute 'strategyOnMismatch'. */ | |
118 | private static final String STRATEGY_ON_MISMATCH_ALLOWED_VALUE = "allowed"; | |
119 | ||
120 | /** Value "disallowed" for attribute 'strategyOnMismatch'. */ | |
121 | private static final String STRATEGY_ON_MISMATCH_DISALLOWED_VALUE = "disallowed"; | |
122 | ||
123 | /** Qualified name for element 'subpackage'. */ | |
124 | private static final String SUBPACKAGE_ELEMENT_NAME = "subpackage"; | |
125 | ||
126 | /** Qualified name for element 'file'. */ | |
127 | private static final String FILE_ELEMENT_NAME = "file"; | |
128 | ||
129 | /** Qualified name for element 'allow'. */ | |
130 | private static final String ALLOW_ELEMENT_NAME = "allow"; | |
131 | ||
132 | /** Used to hold the {@link AbstractImportControl} objects. */ | |
133 |
1
1. <init> : removed call to java/util/ArrayDeque::<init> → KILLED |
private final Deque<AbstractImportControl> stack = new ArrayDeque<>(); |
134 | ||
135 | static { | |
136 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_0, DTD_RESOURCE_NAME_1_0); | |
137 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_1, DTD_RESOURCE_NAME_1_1); | |
138 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_2, DTD_RESOURCE_NAME_1_2); | |
139 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_3, DTD_RESOURCE_NAME_1_3); | |
140 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_ID_1_4, DTD_RESOURCE_NAME_1_4); | |
141 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_CS_ID_1_0, DTD_RESOURCE_NAME_1_0); | |
142 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_CS_ID_1_1, DTD_RESOURCE_NAME_1_1); | |
143 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_CS_ID_1_2, DTD_RESOURCE_NAME_1_2); | |
144 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_CS_ID_1_3, DTD_RESOURCE_NAME_1_3); | |
145 | DTD_RESOURCE_BY_ID.put(DTD_PUBLIC_CS_ID_1_4, DTD_RESOURCE_NAME_1_4); | |
146 | } | |
147 | ||
148 | /** | |
149 | * Constructs an instance. | |
150 | * | |
151 | * @throws ParserConfigurationException if an error occurs. | |
152 | * @throws SAXException if an error occurs. | |
153 | */ | |
154 | private ImportControlLoader() throws ParserConfigurationException, | |
155 | SAXException { | |
156 | super(DTD_RESOURCE_BY_ID); | |
157 | } | |
158 | ||
159 | @Override | |
160 | public void startElement(String namespaceUri, | |
161 | String localName, | |
162 | String qName, | |
163 | Attributes attributes) | |
164 | throws SAXException { | |
165 |
3
1. startElement : negated conditional → KILLED 2. startElement : removed conditional - replaced equality check with false → KILLED 3. startElement : removed conditional - replaced equality check with true → KILLED |
if ("import-control".equals(qName)) { |
166 | final String pkg = safeGet(attributes, PKG_ATTRIBUTE_NAME); | |
167 | final MismatchStrategy strategyOnMismatch = getStrategyForImportControl(attributes); | |
168 | final boolean regex = containsRegexAttribute(attributes); | |
169 |
2
1. startElement : removed call to com/puppycrawl/tools/checkstyle/checks/imports/PkgImportControl::<init> → KILLED 2. startElement : removed call to java/util/Deque::push → KILLED |
stack.push(new PkgImportControl(pkg, regex, strategyOnMismatch)); |
170 | } | |
171 |
3
1. startElement : negated conditional → KILLED 2. startElement : removed conditional - replaced equality check with false → KILLED 3. startElement : removed conditional - replaced equality check with true → KILLED |
else if (SUBPACKAGE_ELEMENT_NAME.equals(qName)) { |
172 | final String name = safeGet(attributes, NAME_ATTRIBUTE_NAME); | |
173 | final MismatchStrategy strategyOnMismatch = getStrategyForSubpackage(attributes); | |
174 | final boolean regex = containsRegexAttribute(attributes); | |
175 | final PkgImportControl parentImportControl = (PkgImportControl) stack.peek(); | |
176 |
1
1. startElement : removed call to com/puppycrawl/tools/checkstyle/checks/imports/PkgImportControl::<init> → KILLED |
final AbstractImportControl importControl = new PkgImportControl(parentImportControl, |
177 | name, regex, strategyOnMismatch); | |
178 |
1
1. startElement : removed call to com/puppycrawl/tools/checkstyle/checks/imports/PkgImportControl::addChild → KILLED |
parentImportControl.addChild(importControl); |
179 |
1
1. startElement : removed call to java/util/Deque::push → KILLED |
stack.push(importControl); |
180 | } | |
181 |
3
1. startElement : negated conditional → KILLED 2. startElement : removed conditional - replaced equality check with false → KILLED 3. startElement : removed conditional - replaced equality check with true → KILLED |
else if (FILE_ELEMENT_NAME.equals(qName)) { |
182 | final String name = safeGet(attributes, NAME_ATTRIBUTE_NAME); | |
183 | final boolean regex = containsRegexAttribute(attributes); | |
184 | final PkgImportControl parentImportControl = (PkgImportControl) stack.peek(); | |
185 |
1
1. startElement : removed call to com/puppycrawl/tools/checkstyle/checks/imports/FileImportControl::<init> → KILLED |
final AbstractImportControl importControl = new FileImportControl(parentImportControl, |
186 | name, regex); | |
187 |
1
1. startElement : removed call to com/puppycrawl/tools/checkstyle/checks/imports/PkgImportControl::addChild → KILLED |
parentImportControl.addChild(importControl); |
188 |
1
1. startElement : removed call to java/util/Deque::push → KILLED |
stack.push(importControl); |
189 | } | |
190 |
6
1. startElement : removed conditional - replaced equality check with false → SURVIVED 2. startElement : removed conditional - replaced equality check with true → SURVIVED 3. startElement : negated conditional → KILLED 4. startElement : negated conditional → KILLED 5. startElement : removed conditional - replaced equality check with false → KILLED 6. startElement : removed conditional - replaced equality check with true → KILLED |
else if (ALLOW_ELEMENT_NAME.equals(qName) || "disallow".equals(qName)) { |
191 | final AbstractImportRule rule = createImportRule(qName, attributes); | |
192 |
1
1. startElement : removed call to com/puppycrawl/tools/checkstyle/checks/imports/AbstractImportControl::addImportRule → KILLED |
stack.peek().addImportRule(rule); |
193 | } | |
194 | } | |
195 | ||
196 | /** | |
197 | * Constructs an instance of an import rule based on the given {@code name} and | |
198 | * {@code attributes}. | |
199 | * | |
200 | * @param qName The qualified name. | |
201 | * @param attributes The attributes attached to the element. | |
202 | * @return The created import rule. | |
203 | * @throws SAXException if an error occurs. | |
204 | */ | |
205 | private static AbstractImportRule createImportRule(String qName, Attributes attributes) | |
206 | throws SAXException { | |
207 | // Need to handle either "pkg" or "class" attribute. | |
208 | // May have "exact-match" for "pkg" | |
209 | // May have "local-only" | |
210 | final boolean isAllow = ALLOW_ELEMENT_NAME.equals(qName); | |
211 |
3
1. createImportRule : negated conditional → KILLED 2. createImportRule : removed conditional - replaced equality check with false → KILLED 3. createImportRule : removed conditional - replaced equality check with true → KILLED |
final boolean isLocalOnly = attributes.getValue("local-only") != null; |
212 | final String pkg = attributes.getValue(PKG_ATTRIBUTE_NAME); | |
213 | final boolean regex = containsRegexAttribute(attributes); | |
214 | final AbstractImportRule rule; | |
215 |
3
1. createImportRule : negated conditional → KILLED 2. createImportRule : removed conditional - replaced equality check with false → KILLED 3. createImportRule : removed conditional - replaced equality check with true → KILLED |
if (pkg == null) { |
216 | // handle class names which can be normal class names or regular | |
217 | // expressions | |
218 | final String clazz = safeGet(attributes, "class"); | |
219 |
1
1. createImportRule : removed call to com/puppycrawl/tools/checkstyle/checks/imports/ClassImportRule::<init> → KILLED |
rule = new ClassImportRule(isAllow, isLocalOnly, clazz, regex); |
220 | } | |
221 | else { | |
222 | final boolean exactMatch = | |
223 |
3
1. createImportRule : negated conditional → KILLED 2. createImportRule : removed conditional - replaced equality check with false → KILLED 3. createImportRule : removed conditional - replaced equality check with true → KILLED |
attributes.getValue("exact-match") != null; |
224 |
1
1. createImportRule : removed call to com/puppycrawl/tools/checkstyle/checks/imports/PkgImportRule::<init> → KILLED |
rule = new PkgImportRule(isAllow, isLocalOnly, pkg, exactMatch, regex); |
225 | } | |
226 |
1
1. createImportRule : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::createImportRule to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return rule; |
227 | } | |
228 | ||
229 | /** | |
230 | * Check if the given attributes contain the regex attribute. | |
231 | * | |
232 | * @param attributes the attributes. | |
233 | * @return if the regex attribute is contained. | |
234 | */ | |
235 | private static boolean containsRegexAttribute(Attributes attributes) { | |
236 |
5
1. containsRegexAttribute : replaced boolean return with true for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::containsRegexAttribute → KILLED 2. containsRegexAttribute : negated conditional → KILLED 3. containsRegexAttribute : removed conditional - replaced equality check with false → KILLED 4. containsRegexAttribute : removed conditional - replaced equality check with true → KILLED 5. containsRegexAttribute : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED |
return attributes.getValue("regex") != null; |
237 | } | |
238 | ||
239 | @Override | |
240 | public void endElement(String namespaceUri, String localName, | |
241 | String qName) { | |
242 |
6
1. endElement : negated conditional → KILLED 2. endElement : negated conditional → KILLED 3. endElement : removed conditional - replaced equality check with false → KILLED 4. endElement : removed conditional - replaced equality check with false → KILLED 5. endElement : removed conditional - replaced equality check with true → KILLED 6. endElement : removed conditional - replaced equality check with true → KILLED |
if (SUBPACKAGE_ELEMENT_NAME.equals(qName) || FILE_ELEMENT_NAME.equals(qName)) { |
243 | stack.pop(); | |
244 | } | |
245 | } | |
246 | ||
247 | /** | |
248 | * Loads the import control file from a file. | |
249 | * | |
250 | * @param uri the uri of the file to load. | |
251 | * @return the root {@link PkgImportControl} object. | |
252 | * @throws CheckstyleException if an error occurs. | |
253 | */ | |
254 | public static PkgImportControl load(URI uri) throws CheckstyleException { | |
255 |
1
1. load : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::load to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return loadUri(uri); |
256 | } | |
257 | ||
258 | /** | |
259 | * Loads the import control file from a {@link InputSource}. | |
260 | * | |
261 | * @param source the source to load from. | |
262 | * @param uri uri of the source being loaded. | |
263 | * @return the root {@link PkgImportControl} object. | |
264 | * @throws CheckstyleException if an error occurs. | |
265 | */ | |
266 | private static PkgImportControl load(InputSource source, | |
267 | URI uri) throws CheckstyleException { | |
268 | try { | |
269 |
1
1. load : removed call to com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::<init> → KILLED |
final ImportControlLoader loader = new ImportControlLoader(); |
270 |
1
1. load : removed call to com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::parseInputSource → KILLED |
loader.parseInputSource(source); |
271 |
1
1. load : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::load to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return loader.getRoot(); |
272 | } | |
273 | catch (ParserConfigurationException | SAXException ex) { | |
274 |
1
1. load : removed call to java/lang/StringBuilder::<init> → KILLED |
throw new CheckstyleException("unable to parse " + uri |
275 |
1
1. load : removed call to com/puppycrawl/tools/checkstyle/api/CheckstyleException::<init> → KILLED |
+ " - " + ex.getMessage(), ex); |
276 | } | |
277 | catch (IOException ex) { | |
278 |
2
1. load : removed call to java/lang/StringBuilder::<init> → KILLED 2. load : removed call to com/puppycrawl/tools/checkstyle/api/CheckstyleException::<init> → KILLED |
throw new CheckstyleException("unable to read " + uri, ex); |
279 | } | |
280 | } | |
281 | ||
282 | /** | |
283 | * Loads the import control file from a URI. | |
284 | * | |
285 | * @param uri the uri of the file to load. | |
286 | * @return the root {@link PkgImportControl} object. | |
287 | * @throws CheckstyleException if an error occurs. | |
288 | */ | |
289 | private static PkgImportControl loadUri(URI uri) throws CheckstyleException { | |
290 | try (InputStream inputStream = uri.toURL().openStream()) { | |
291 |
1
1. loadUri : removed call to org/xml/sax/InputSource::<init> → KILLED |
final InputSource source = new InputSource(inputStream); |
292 |
1
1. loadUri : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::loadUri to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return load(source, uri); |
293 | } | |
294 | catch (MalformedURLException ex) { | |
295 |
2
1. loadUri : removed call to java/lang/StringBuilder::<init> → KILLED 2. loadUri : removed call to com/puppycrawl/tools/checkstyle/api/CheckstyleException::<init> → KILLED |
throw new CheckstyleException("syntax error in url " + uri, ex); |
296 | } | |
297 | catch (IOException ex) { | |
298 |
2
1. loadUri : removed call to java/lang/StringBuilder::<init> → KILLED 2. loadUri : removed call to com/puppycrawl/tools/checkstyle/api/CheckstyleException::<init> → KILLED |
throw new CheckstyleException("unable to find " + uri, ex); |
299 | } | |
300 | } | |
301 | ||
302 | /** | |
303 | * Returns root PkgImportControl. | |
304 | * | |
305 | * @return the root {@link PkgImportControl} object loaded. | |
306 | */ | |
307 | private PkgImportControl getRoot() { | |
308 |
1
1. getRoot : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::getRoot to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return (PkgImportControl) stack.peek(); |
309 | } | |
310 | ||
311 | /** | |
312 | * Utility to get a strategyOnMismatch property for "import-control" tag. | |
313 | * | |
314 | * @param attributes collect to get attribute from. | |
315 | * @return the value of the attribute. | |
316 | */ | |
317 | private static MismatchStrategy getStrategyForImportControl(Attributes attributes) { | |
318 | final String returnValue = attributes.getValue(STRATEGY_ON_MISMATCH_ATTRIBUTE_NAME); | |
319 | MismatchStrategy strategyOnMismatch = MismatchStrategy.DISALLOWED; | |
320 |
3
1. getStrategyForImportControl : negated conditional → KILLED 2. getStrategyForImportControl : removed conditional - replaced equality check with false → KILLED 3. getStrategyForImportControl : removed conditional - replaced equality check with true → KILLED |
if (STRATEGY_ON_MISMATCH_ALLOWED_VALUE.equals(returnValue)) { |
321 | strategyOnMismatch = MismatchStrategy.ALLOWED; | |
322 | } | |
323 |
1
1. getStrategyForImportControl : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::getStrategyForImportControl to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return strategyOnMismatch; |
324 | } | |
325 | ||
326 | /** | |
327 | * Utility to get a strategyOnMismatch property for "subpackage" tag. | |
328 | * | |
329 | * @param attributes collect to get attribute from. | |
330 | * @return the value of the attribute. | |
331 | */ | |
332 | private static MismatchStrategy getStrategyForSubpackage(Attributes attributes) { | |
333 | final String returnValue = attributes.getValue(STRATEGY_ON_MISMATCH_ATTRIBUTE_NAME); | |
334 | MismatchStrategy strategyOnMismatch = MismatchStrategy.DELEGATE_TO_PARENT; | |
335 |
3
1. getStrategyForSubpackage : negated conditional → KILLED 2. getStrategyForSubpackage : removed conditional - replaced equality check with false → KILLED 3. getStrategyForSubpackage : removed conditional - replaced equality check with true → KILLED |
if (STRATEGY_ON_MISMATCH_ALLOWED_VALUE.equals(returnValue)) { |
336 | strategyOnMismatch = MismatchStrategy.ALLOWED; | |
337 | } | |
338 |
3
1. getStrategyForSubpackage : negated conditional → KILLED 2. getStrategyForSubpackage : removed conditional - replaced equality check with false → KILLED 3. getStrategyForSubpackage : removed conditional - replaced equality check with true → KILLED |
else if (STRATEGY_ON_MISMATCH_DISALLOWED_VALUE.equals(returnValue)) { |
339 | strategyOnMismatch = MismatchStrategy.DISALLOWED; | |
340 | } | |
341 |
1
1. getStrategyForSubpackage : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::getStrategyForSubpackage to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return strategyOnMismatch; |
342 | } | |
343 | ||
344 | /** | |
345 | * Utility to safely get an attribute. If it does not exist an exception | |
346 | * is thrown. | |
347 | * | |
348 | * @param attributes collect to get attribute from. | |
349 | * @param name name of the attribute to get. | |
350 | * @return the value of the attribute. | |
351 | * @throws SAXException if the attribute does not exist. | |
352 | */ | |
353 | private static String safeGet(Attributes attributes, String name) | |
354 | throws SAXException { | |
355 | final String returnValue = attributes.getValue(name); | |
356 |
3
1. safeGet : negated conditional → KILLED 2. safeGet : removed conditional - replaced equality check with false → KILLED 3. safeGet : removed conditional - replaced equality check with true → KILLED |
if (returnValue == null) { |
357 | // -@cs[IllegalInstantiation] SAXException is in the overridden method signature | |
358 | // of the only method which calls the current one | |
359 |
2
1. safeGet : removed call to java/lang/StringBuilder::<init> → KILLED 2. safeGet : removed call to org/xml/sax/SAXException::<init> → KILLED |
throw new SAXException("missing attribute " + name); |
360 | } | |
361 |
1
1. safeGet : mutated return of Object value for com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoader::safeGet to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return returnValue; |
362 | } | |
363 | ||
364 | } | |
Mutations | ||
133 |
1.1 |
|
165 |
1.1 2.2 3.3 |
|
169 |
1.1 2.2 |
|
171 |
1.1 2.2 3.3 |
|
176 |
1.1 |
|
178 |
1.1 |
|
179 |
1.1 |
|
181 |
1.1 2.2 3.3 |
|
185 |
1.1 |
|
187 |
1.1 |
|
188 |
1.1 |
|
190 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
192 |
1.1 |
|
211 |
1.1 2.2 3.3 |
|
215 |
1.1 2.2 3.3 |
|
219 |
1.1 |
|
223 |
1.1 2.2 3.3 |
|
224 |
1.1 |
|
226 |
1.1 |
|
236 |
1.1 2.2 3.3 4.4 5.5 |
|
242 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
255 |
1.1 |
|
269 |
1.1 |
|
270 |
1.1 |
|
271 |
1.1 |
|
274 |
1.1 |
|
275 |
1.1 |
|
278 |
1.1 2.2 |
|
291 |
1.1 |
|
292 |
1.1 |
|
295 |
1.1 2.2 |
|
298 |
1.1 2.2 |
|
308 |
1.1 |
|
320 |
1.1 2.2 3.3 |
|
323 |
1.1 |
|
335 |
1.1 2.2 3.3 |
|
338 |
1.1 2.2 3.3 |
|
341 |
1.1 |
|
356 |
1.1 2.2 3.3 |
|
359 |
1.1 2.2 |
|
361 |
1.1 |