File ConfigParser.java
has 675 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* ConfigParser.java
Purpose:
Description:
Method parse
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
public void parse(Element root, Configuration config, Locator locator) throws Exception {
l_out: for (Iterator it = root.getElements().iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String elnm = el.getName();
// B65-ZK-1671: ThemeProvider specified in metainfo/zk/zk.xml may get overridden by default
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseDesktopConfig
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
private static void parseDesktopConfig(Configuration config, Element conf) throws Exception {
//theme-uri
for (Iterator<Element> it = conf.getElements("theme-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String uri = el.getText(true);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseClientConfig
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private static void parseClientConfig(Configuration config, Element conf) {
Integer v = parseInteger(conf, "processing-prompt-delay", POSITIVE_ONLY);
if (v != null)
config.setProcessingPromptDelay(v.intValue());
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseSystemConfig
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
@SuppressWarnings("deprecation")
private static void parseSystemConfig(Configuration config, Element el) throws Exception {
String s = el.getElementValue("disable-event-thread", true);
if (s != null) {
final boolean enable = "false".equals(s);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseConfigXml
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public void parseConfigXml(Configuration config) {
boolean syscfgLoaded;
boolean syscfgLoadedConfig;
synchronized (ConfigParser.class) {
syscfgLoaded = _syscfgLoaded;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parse
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void parse(Element root, Configuration config, Locator locator) throws Exception {
l_out: for (Iterator it = root.getElements().iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String elnm = el.getName();
// B65-ZK-1671: ThemeProvider specified in metainfo/zk/zk.xml may get overridden by default
Method parseSystemConfig
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("deprecation")
private static void parseSystemConfig(Configuration config, Element el) throws Exception {
String s = el.getElementValue("disable-event-thread", true);
if (s != null) {
final boolean enable = "false".equals(s);
ConfigParser
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
public class ConfigParser {
private static final Logger log = LoggerFactory.getLogger(ConfigParser.class);
/** The number of segments in a version.
*/
Method parseClientConfig
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void parseClientConfig(Configuration config, Element conf) {
Integer v = parseInteger(conf, "processing-prompt-delay", POSITIVE_ONLY);
if (v != null)
config.setProcessingPromptDelay(v.intValue());
Method parseLibProperty
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static void parseLibProperty(Element el) {
final String nm = IDOMs.getRequiredElementValue(el, "name");
Element valueElmn = el.getElement("value");
Element appendableElmn = el.getElement("appendable");
boolean appendable = appendableElmn != null ? "true".equals(appendableElmn.getText(true)) : false;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseDesktopConfig
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void parseDesktopConfig(Configuration config, Element conf) throws Exception {
//theme-uri
for (Iterator<Element> it = conf.getElements("theme-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String uri = el.getText(true);
Method parseClass
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private static <T> Class<T> parseClass(Element el, String elnm, Class<?> cls, boolean required) {
//Note: we throw exception rather than warning to make sure
//the developer correct it
final String clsnm = el.getElementValue(elnm, true);
if (clsnm != null && clsnm.length() != 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseConfigXml
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void parseConfigXml(Configuration config) {
boolean syscfgLoaded;
boolean syscfgLoadedConfig;
synchronized (ConfigParser.class) {
syscfgLoaded = _syscfgLoaded;
Method parseSubSystemConfig
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static void parseSubSystemConfig(Configuration config, Element root) throws Exception {
for (Element el : root.getElements("system-config")) {
if (config != null) {
parseSystemConfig(config, el);
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method checkVersion
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean checkVersion(URL url, Document doc, boolean zk5required) throws Exception {
final Element el = doc.getRootElement().getElement("version");
if (el == null)
return true; //version is optional (3.0.5)
Method checkVersion
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static boolean checkVersion(URL url, Document doc, boolean zk5required) throws Exception {
final Element el = doc.getRootElement().getElement("version");
if (el == null)
return true; //version is optional (3.0.5)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseLibProperty
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void parseLibProperty(Element el) {
final String nm = IDOMs.getRequiredElementValue(el, "name");
Element valueElmn = el.getElement("value");
Element appendableElmn = el.getElement("appendable");
boolean appendable = appendableElmn != null ? "true".equals(appendableElmn.getText(true)) : false;
Method parseInteger
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static Integer parseInteger(Element el, String subnm, int flag) throws UiException {
//Note: we throw exception rather than warning to make sure
//the developer correct it
String val = el.getElementValue(subnm, true);
if (val != null && val.length() > 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return true; //matched
Avoid too many return
statements within this method. Open
return false;
Method parseLangConfig
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private static void parseLangConfig(Locator locator, Element conf) {
for (Iterator it = conf.getElements("addon-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String path = el.getText(true);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (Iterator it = conf.getElements("addon-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String path = el.getText(true);
final URL url = locator.getResource(path);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (Iterator it = conf.getElements("language-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String path = el.getText(true);
final URL url = locator.getResource(path);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 96.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (!config.isCustomThemeResolver()) {
cls = parseClass(conf, "theme-resolver-class", ThemeResolver.class);
if (cls != null) {
if (!cls.getName().startsWith("org.zkoss."))
config.setCustomThemeResolver(true);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 86.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (!config.isCustomThemeProvider()) {
cls = parseClass(conf, "theme-provider-class", ThemeProvider.class);
if (cls != null) {
if (!cls.getName().startsWith("org.zkoss."))
config.setCustomThemeProvider(true);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 86.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (!config.isCustomThemeRegistry()) {
cls = parseClass(conf, "theme-registry-class", ThemeRegistry.class);
if (cls != null) {
if (!cls.getName().startsWith("org.zkoss."))
config.setCustomThemeRegistry(true);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 86.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (Iterator<Element> it = conf.getElements("disable-theme-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String uri = el.getText(true);
if (uri.length() != 0)
config.addDisabledThemeURI(uri);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 62.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (Iterator<Element> it = conf.getElements("theme-uri").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
final String uri = el.getText(true);
if (uri.length() != 0)
config.addThemeURI(uri);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 62.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
private static void parseSubZScriptConfig(Element root) {
for (Iterator it = root.getElements("zscript-config").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
Interpreters.add(el);
//Note: zscript-config is applied to the whole system, not just langdef
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 44.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
private static void parseSubDeviceConfig(Element root) {
for (Iterator it = root.getElements("device-config").iterator(); it.hasNext();) {
final Element el = (Element) it.next();
Devices.add(el);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 44.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76