Commit f88dba65 authored by Johannes Salentin's avatar Johannes Salentin
Browse files

formatting of long lines

parent e4fe771f
Pipeline #441311 passed with stages
in 1 minute and 27 seconds
...@@ -31,14 +31,16 @@ public class EASmellDetector { ...@@ -31,14 +31,16 @@ public class EASmellDetector {
detectors.add(new StrictLayersViolation()); detectors.add(new StrictLayersViolation());
detectors.add(new WeakenedModularity()); detectors.add(new WeakenedModularity());
// detect each smell
System.out.print("\n"); System.out.print("\n");
long startTotalTime = System.nanoTime(); long startTotalTime = System.nanoTime();
for (Detector detector : detectors) { for (Detector detector : detectors) {
System.out.println("Start detection of " + detector.getSmellName() + " ..."); System.out.println("Start detection of " + detector.getSmellName() + " ...");
long startTime = System.nanoTime(); long startTime = System.nanoTime();
long startMemory = calculateMemoryConsumption(); long startMemory = calculateMemoryConsumption();
// detect each smell
printSmells(detector.detect()); printSmells(detector.detect());
String time = calculateTimeConsumption(startTime); String time = calculateTimeConsumption(startTime);
String memory = formatMemoryConsumption(calculateMemoryConsumption() - startMemory); String memory = formatMemoryConsumption(calculateMemoryConsumption() - startMemory);
System.out.println("Finished detection of " + detector.getSmellName() + " in " + time + " (" + memory + ")\n"); System.out.println("Finished detection of " + detector.getSmellName() + " in " + time + " (" + memory + ")\n");
......
...@@ -12,6 +12,9 @@ import javax.xml.validation.Schema; ...@@ -12,6 +12,9 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import java.io.File; import java.io.File;
/**
* Class for binding XML to Java Objects using JAXB
*/
public class JAXBMarshalUnmarshal { public class JAXBMarshalUnmarshal {
/** /**
...@@ -54,8 +57,6 @@ public class JAXBMarshalUnmarshal { ...@@ -54,8 +57,6 @@ public class JAXBMarshalUnmarshal {
marshaller.marshal(jaxbElement, new File(xmlFile)); marshaller.marshal(jaxbElement, new File(xmlFile));
} }
/*Schema schema = (xsdSchema == null || xsdSchema.trim().length() == 0)
? null : schemaFactory.newSchema(new File(xsdSchema));*/
private static Schema createSchema(String xsdSchema) throws SAXException { private static Schema createSchema(String xsdSchema) throws SAXException {
if (xsdSchema == null || xsdSchema.trim().length() == 0) { if (xsdSchema == null || xsdSchema.trim().length() == 0) {
return null; return null;
......
...@@ -13,7 +13,8 @@ public class AmbiguousViewpoint extends Detector { ...@@ -13,7 +13,8 @@ public class AmbiguousViewpoint extends Detector {
public List<EASmell> detect() { public List<EASmell> detect() {
for (Diagram view : model.getViews()) { for (Diagram view : model.getViews()) {
if (view.getViewpoint() == null) { if (view.getViewpoint() == null) {
addToSmells(new EASmell(getSmellName(), null, " at the View \"" + view.getNameGroup().get(0).getValue() + "\" (" + view.getIdentifier() + ")")); addToSmells(new EASmell(getSmellName(), null, " at the View \"" + view.getNameGroup().get(0).getValue()
+ "\" (" + view.getIdentifier() + ")"));
} }
} }
return result; return result;
......
...@@ -23,7 +23,8 @@ public class ChattyService extends Detector { ...@@ -23,7 +23,8 @@ public class ChattyService extends Detector {
if (model.isNotStructural(relationship)) { if (model.isNotStructural(relationship)) {
ElementType source = (ElementType) relationship.getSource(); ElementType source = (ElementType) relationship.getSource();
ElementType target = (ElementType) relationship.getTarget(); ElementType target = (ElementType) relationship.getTarget();
if (serviceElements.contains(source) && serviceElements.contains(target) && (serviceElement.equals(source) || serviceElement.equals(target))) { if (serviceElements.contains(source) && serviceElements.contains(target)
&& (serviceElement.equals(source) || serviceElement.equals(target))) {
relationCount++; relationCount++;
} }
} }
......
...@@ -12,8 +12,8 @@ public class DataService extends Detector { ...@@ -12,8 +12,8 @@ public class DataService extends Detector {
} }
public List<EASmell> detect() { public List<EASmell> detect() {
List<ElementType> serviceElements = model.getElements().stream().filter(e -> List<ElementType> serviceElements = model.getElements().stream().filter(e
e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList()); -> e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> dataElements = model.getElementsOfType(new String[]{"BusinessObject", "DataObject", "SystemSoftware"}); List<ElementType> dataElements = model.getElementsOfType(new String[]{"BusinessObject", "DataObject", "SystemSoftware"});
for (ElementType serviceElement : serviceElements) { for (ElementType serviceElement : serviceElements) {
List<ElementType> referencedElements = model.getReferencedElementsOf(serviceElement); List<ElementType> referencedElements = model.getReferencedElementsOf(serviceElement);
......
...@@ -26,7 +26,8 @@ public class DeadComponent extends Detector { ...@@ -26,7 +26,8 @@ public class DeadComponent extends Detector {
ElementType target = (ElementType) relationship.getTarget(); ElementType target = (ElementType) relationship.getTarget();
ElementType source = (ElementType) relationship.getSource(); ElementType source = (ElementType) relationship.getSource();
// relationship to element outside the cluster -> so it is used // relationship to element outside the cluster -> so it is used
if ((cluster.contains(source) && !cluster.contains(target)) || (cluster.contains(target) && !cluster.contains(source))) { if ((cluster.contains(source) && !cluster.contains(target))
|| (cluster.contains(target) && !cluster.contains(source))) {
used = true; used = true;
break; break;
} }
......
...@@ -17,7 +17,8 @@ public class Documentation extends Detector { ...@@ -17,7 +17,8 @@ public class Documentation extends Detector {
for (ElementType element : model.getElements()) { for (ElementType element : model.getElements()) {
for (PreservedLangStringType documentation : element.getDocumentation()) { for (PreservedLangStringType documentation : element.getDocumentation()) {
if (documentation.getValue().length() > MAX_DOCUMENTATION_LENGTH) { if (documentation.getValue().length() > MAX_DOCUMENTATION_LENGTH) {
addToSmells(new EASmell(getSmellName(), element, " with a documentation of length " + documentation.getValue().length())); addToSmells(new EASmell(getSmellName(), element, " with a documentation of length "
+ documentation.getValue().length()));
break; break;
} }
} }
......
...@@ -28,8 +28,8 @@ public class Duplication extends Detector { ...@@ -28,8 +28,8 @@ public class Duplication extends Detector {
} }
} }
if (((double) 2 * duplicatedWords) / (ei.size() + ej.size()) > DUPLICATED_WORDS_RATIO) { if (((double) 2 * duplicatedWords) / (ei.size() + ej.size()) > DUPLICATED_WORDS_RATIO) {
addToSmells(new EASmell(getSmellName(), elements.get(i), " together with" + " \"" + addToSmells(new EASmell(getSmellName(), elements.get(i), " together with" + " \""
elements.get(j).getNameGroup().get(0).getValue() + "\" (" + elements.get(j).getIdentifier() + ")")); + elements.get(j).getNameGroup().get(0).getValue() + "\" (" + elements.get(j).getIdentifier() + ")"));
} }
} }
} }
......
...@@ -36,7 +36,7 @@ public class EASmell { ...@@ -36,7 +36,7 @@ public class EASmell {
} }
public String toString() { public String toString() {
return smellName + " detected" + ((element == null) ? "" : " at the " + element.getClass().getSimpleName() + " \"" + return smellName + " detected" + ((element == null) ? "" : " at the " + element.getClass().getSimpleName() + " \""
getElementName() + "\" (" + element.getIdentifier() + ")") + (context == null ? "" : context); + getElementName() + "\" (" + element.getIdentifier() + ")") + (context == null ? "" : context);
} }
} }
...@@ -32,7 +32,8 @@ public class HubLikeModularization extends Detector { ...@@ -32,7 +32,8 @@ public class HubLikeModularization extends Detector {
} }
} }
if (fanIn > LARGE_FAN_IN && fanOut > LARGE_FAN_OUT) { if (fanIn > LARGE_FAN_IN && fanOut > LARGE_FAN_OUT) {
addToSmells(new EASmell("Hub-like Modularization", element, " with a total of " + (fanIn + fanOut) + " relations")); addToSmells(new EASmell("Hub-like Modularization", element, " with a total of "
+ (fanIn + fanOut) + " relations"));
} }
} }
return result; return result;
......
...@@ -16,8 +16,8 @@ public class MessageChain extends Detector { ...@@ -16,8 +16,8 @@ public class MessageChain extends Detector {
// restricted to Service Chains // restricted to Service Chains
public List<EASmell> detect() { public List<EASmell> detect() {
List<ElementType> serviceElements = model.getElements().stream().filter(e -> List<ElementType> serviceElements = model.getElements().stream().filter(e
e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList()); -> e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
for (ElementType element : serviceElements) { for (ElementType element : serviceElements) {
List<ElementType> chain = getServiceChain(element); List<ElementType> chain = getServiceChain(element);
if (chain.size() > MAX_SERVICE_CHAIN_LENGTH) { if (chain.size() > MAX_SERVICE_CHAIN_LENGTH) {
...@@ -26,7 +26,8 @@ public class MessageChain extends Detector { ...@@ -26,7 +26,8 @@ public class MessageChain extends Detector {
elementsInChain.append(e.getNameGroup().get(0).getValue()); elementsInChain.append(e.getNameGroup().get(0).getValue());
elementsInChain.append(", "); elementsInChain.append(", ");
} }
addToSmells(new EASmell(getSmellName(), element, " with a chain length of " + chain.size() + " and the elements: " + elementsInChain)); addToSmells(new EASmell(getSmellName(), element, " with a chain length of " + chain.size()
+ " and the elements: " + elementsInChain));
} }
} }
return result; return result;
...@@ -39,8 +40,8 @@ public class MessageChain extends Detector { ...@@ -39,8 +40,8 @@ public class MessageChain extends Detector {
} }
private List<ElementType> getServiceChain(ElementType start, List<ElementType> current) { private List<ElementType> getServiceChain(ElementType start, List<ElementType> current) {
List<ElementType> referencedServiceElements = model.getReferencedElementsOf(start).stream().filter(e -> List<ElementType> referencedServiceElements = model.getReferencedElementsOf(start).stream().filter(e
e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList()); -> e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> res = new ArrayList<>(); List<ElementType> res = new ArrayList<>();
// no further referenced services // no further referenced services
if (referencedServiceElements.isEmpty()) { if (referencedServiceElements.isEmpty()) {
......
...@@ -12,8 +12,8 @@ public class SharedPersistency extends Detector { ...@@ -12,8 +12,8 @@ public class SharedPersistency extends Detector {
} }
public List<EASmell> detect() { public List<EASmell> detect() {
List<ElementType> databaseElements = model.getElements().stream().filter(e -> e.getClass().getSimpleName().equals("SystemSoftware") && List<ElementType> databaseElements = model.getElements().stream().filter(e -> e.getClass().getSimpleName().equals("SystemSoftware")
(e.getNameGroup().get(0).getValue().contains("database") || e.getNameGroup().get(0).getValue().contains("DBMS"))).collect(Collectors.toList()); && (e.getNameGroup().get(0).getValue().contains("database") || e.getNameGroup().get(0).getValue().contains("DBMS"))).collect(Collectors.toList());
for (ElementType databaseElement : databaseElements) { for (ElementType databaseElement : databaseElements) {
String[] types = {"Association", "Realization", "Assignment"}; String[] types = {"Association", "Realization", "Assignment"};
List<ElementType> referencedElements = model.getReferencedElementsOf(databaseElement, types); List<ElementType> referencedElements = model.getReferencedElementsOf(databaseElement, types);
......
...@@ -20,8 +20,8 @@ public class StrictLayersViolation extends Detector { ...@@ -20,8 +20,8 @@ public class StrictLayersViolation extends Detector {
ElementType target = (ElementType) relationship.getTarget(); ElementType target = (ElementType) relationship.getTarget();
if ((businessElements.contains(source) && technologyElements.contains(target) || if ((businessElements.contains(source) && technologyElements.contains(target) ||
(businessElements.contains(target) && technologyElements.contains(source)))) { (businessElements.contains(target) && technologyElements.contains(source)))) {
addToSmells(new EASmell(getSmellName(), source, " with the " + target.getClass().getSimpleName() + " \"" + addToSmells(new EASmell(getSmellName(), source, " with the " + target.getClass().getSimpleName() + " \""
target.getNameGroup().get(0).getValue() + "\" (" + target.getIdentifier() + ")")); + target.getNameGroup().get(0).getValue() + "\" (" + target.getIdentifier() + ")"));
} }
} }
} }
......
...@@ -25,8 +25,8 @@ public class WeakenedModularity extends Detector { ...@@ -25,8 +25,8 @@ public class WeakenedModularity extends Detector {
ElementType source = (ElementType) relationship.getSource(); ElementType source = (ElementType) relationship.getSource();
if (cluster.contains(source) && cluster.contains(target)) { if (cluster.contains(source) && cluster.contains(target)) {
internal++; internal++;
} else if (model.isNotStructural(relationship) && } else if (model.isNotStructural(relationship)
((cluster.contains(source) && !cluster.contains(target)) || (cluster.contains(target) && !cluster.contains(source)))) { && ((cluster.contains(source) && !cluster.contains(target)) || (cluster.contains(target) && !cluster.contains(source)))) {
external++; external++;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment