Commit f88dba65 authored by Johannes Salentin's avatar Johannes Salentin

formatting of long lines

parent e4fe771f
Pipeline #163392 passed with stages
in 1 minute and 19 seconds
......@@ -31,14 +31,16 @@ public class EASmellDetector {
detectors.add(new StrictLayersViolation());
detectors.add(new WeakenedModularity());
// detect each smell
System.out.print("\n");
long startTotalTime = System.nanoTime();
for (Detector detector : detectors) {
System.out.println("Start detection of " + detector.getSmellName() + " ...");
long startTime = System.nanoTime();
long startMemory = calculateMemoryConsumption();
// detect each smell
printSmells(detector.detect());
String time = calculateTimeConsumption(startTime);
String memory = formatMemoryConsumption(calculateMemoryConsumption() - startMemory);
System.out.println("Finished detection of " + detector.getSmellName() + " in " + time + " (" + memory + ")\n");
......
......@@ -12,6 +12,9 @@ import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.File;
/**
* Class for binding XML to Java Objects using JAXB
*/
public class JAXBMarshalUnmarshal {
/**
......@@ -54,8 +57,6 @@ public class JAXBMarshalUnmarshal {
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 {
if (xsdSchema == null || xsdSchema.trim().length() == 0) {
return null;
......
......@@ -13,7 +13,8 @@ public class AmbiguousViewpoint extends Detector {
public List<EASmell> detect() {
for (Diagram view : model.getViews()) {
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;
......
......@@ -23,7 +23,8 @@ public class ChattyService extends Detector {
if (model.isNotStructural(relationship)) {
ElementType source = (ElementType) relationship.getSource();
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++;
}
}
......
......@@ -12,8 +12,8 @@ public class DataService extends Detector {
}
public List<EASmell> detect() {
List<ElementType> serviceElements = model.getElements().stream().filter(e ->
e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> serviceElements = model.getElements().stream().filter(e
-> e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> dataElements = model.getElementsOfType(new String[]{"BusinessObject", "DataObject", "SystemSoftware"});
for (ElementType serviceElement : serviceElements) {
List<ElementType> referencedElements = model.getReferencedElementsOf(serviceElement);
......
......@@ -26,7 +26,8 @@ public class DeadComponent extends Detector {
ElementType target = (ElementType) relationship.getTarget();
ElementType source = (ElementType) relationship.getSource();
// 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;
break;
}
......
......@@ -17,7 +17,8 @@ public class Documentation extends Detector {
for (ElementType element : model.getElements()) {
for (PreservedLangStringType documentation : element.getDocumentation()) {
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;
}
}
......
......@@ -28,8 +28,8 @@ public class Duplication extends Detector {
}
}
if (((double) 2 * duplicatedWords) / (ei.size() + ej.size()) > DUPLICATED_WORDS_RATIO) {
addToSmells(new EASmell(getSmellName(), elements.get(i), " together with" + " \"" +
elements.get(j).getNameGroup().get(0).getValue() + "\" (" + elements.get(j).getIdentifier() + ")"));
addToSmells(new EASmell(getSmellName(), elements.get(i), " together with" + " \""
+ elements.get(j).getNameGroup().get(0).getValue() + "\" (" + elements.get(j).getIdentifier() + ")"));
}
}
}
......
......@@ -36,7 +36,7 @@ public class EASmell {
}
public String toString() {
return smellName + " detected" + ((element == null) ? "" : " at the " + element.getClass().getSimpleName() + " \"" +
getElementName() + "\" (" + element.getIdentifier() + ")") + (context == null ? "" : context);
return smellName + " detected" + ((element == null) ? "" : " at the " + element.getClass().getSimpleName() + " \""
+ getElementName() + "\" (" + element.getIdentifier() + ")") + (context == null ? "" : context);
}
}
......@@ -32,7 +32,8 @@ public class HubLikeModularization extends Detector {
}
}
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;
......
......@@ -16,8 +16,8 @@ public class MessageChain extends Detector {
// restricted to Service Chains
public List<EASmell> detect() {
List<ElementType> serviceElements = model.getElements().stream().filter(e ->
e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> serviceElements = model.getElements().stream().filter(e
-> e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
for (ElementType element : serviceElements) {
List<ElementType> chain = getServiceChain(element);
if (chain.size() > MAX_SERVICE_CHAIN_LENGTH) {
......@@ -26,7 +26,8 @@ public class MessageChain extends Detector {
elementsInChain.append(e.getNameGroup().get(0).getValue());
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;
......@@ -39,8 +40,8 @@ public class MessageChain extends Detector {
}
private List<ElementType> getServiceChain(ElementType start, List<ElementType> current) {
List<ElementType> referencedServiceElements = model.getReferencedElementsOf(start).stream().filter(e ->
e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> referencedServiceElements = model.getReferencedElementsOf(start).stream().filter(e
-> e.getClass().getSimpleName().contains("Service")).collect(Collectors.toList());
List<ElementType> res = new ArrayList<>();
// no further referenced services
if (referencedServiceElements.isEmpty()) {
......
......@@ -12,8 +12,8 @@ public class SharedPersistency extends Detector {
}
public List<EASmell> detect() {
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());
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());
for (ElementType databaseElement : databaseElements) {
String[] types = {"Association", "Realization", "Assignment"};
List<ElementType> referencedElements = model.getReferencedElementsOf(databaseElement, types);
......
......@@ -20,8 +20,8 @@ public class StrictLayersViolation extends Detector {
ElementType target = (ElementType) relationship.getTarget();
if ((businessElements.contains(source) && technologyElements.contains(target) ||
(businessElements.contains(target) && technologyElements.contains(source)))) {
addToSmells(new EASmell(getSmellName(), source, " with the " + target.getClass().getSimpleName() + " \"" +
target.getNameGroup().get(0).getValue() + "\" (" + target.getIdentifier() + ")"));
addToSmells(new EASmell(getSmellName(), source, " with the " + target.getClass().getSimpleName() + " \""
+ target.getNameGroup().get(0).getValue() + "\" (" + target.getIdentifier() + ")"));
}
}
}
......
......@@ -25,8 +25,8 @@ public class WeakenedModularity extends Detector {
ElementType source = (ElementType) relationship.getSource();
if (cluster.contains(source) && cluster.contains(target)) {
internal++;
} else if (model.isNotStructural(relationship) &&
((cluster.contains(source) && !cluster.contains(target)) || (cluster.contains(target) && !cluster.contains(source)))) {
} else if (model.isNotStructural(relationship)
&& ((cluster.contains(source) && !cluster.contains(target)) || (cluster.contains(target) && !cluster.contains(source)))) {
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