-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes the
Workspace.countAndLogWarnings()
method with an initial …
…version of something more flexible.
- Loading branch information
1 parent
ab30296
commit 99d4ccc
Showing
63 changed files
with
1,896 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# structurizr-assistant | ||
|
||
[![Maven Central](https://img.shields.io/maven-central/v/com.structurizr/structurizr-assistant.svg?label=Maven%20Central)](https://search.maven.org/artifact/com.structurizr/structurizr-assistant) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencies { | ||
|
||
api project(':structurizr-core') | ||
|
||
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
structurizr-assistant/src/main/java/com/structurizr/assistant/Assistant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.structurizr.assistant; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
abstract class Assistant { | ||
|
||
private final Collection<Recommendation> recommendations = new ArrayList<>(); | ||
|
||
public Collection<Recommendation> getRecommendations() { | ||
return new ArrayList<>(recommendations); | ||
} | ||
|
||
protected void add(Recommendation recommendation) { | ||
if (recommendation != null) { | ||
recommendations.add(recommendation); | ||
} | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
structurizr-assistant/src/main/java/com/structurizr/assistant/DefaultAssistant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.structurizr.assistant; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.assistant.model.*; | ||
import com.structurizr.assistant.view.ContainerViewsForMultipleSoftwareSystemsInspection; | ||
import com.structurizr.assistant.view.EmptyViewsInspection; | ||
import com.structurizr.assistant.view.SystemContextViewsForMultipleSoftwareSystemsInspection; | ||
import com.structurizr.assistant.workspace.WorkspaceScopeInspection; | ||
import com.structurizr.model.*; | ||
|
||
public class DefaultAssistant extends Assistant { | ||
|
||
private static final String ALL_RECOMMENDATIONS = "structurizr.recommendations"; | ||
|
||
public DefaultAssistant(Workspace workspace) { | ||
if (workspace.getProperties().getOrDefault(ALL_RECOMMENDATIONS, "true").equalsIgnoreCase("false")) { | ||
// skip all inspections | ||
return; | ||
} | ||
|
||
runWorkspaceInspections(workspace); | ||
runModelInspections(workspace); | ||
runViewInspections(workspace); | ||
} | ||
|
||
private void runWorkspaceInspections(Workspace workspace) { | ||
add(new WorkspaceScopeInspection(workspace).run()); | ||
} | ||
|
||
private void runModelInspections(Workspace workspace) { | ||
add(new EmptyModelInspection(workspace).run()); | ||
add(new MultipleSoftwareSystemsDetailedInspection(workspace).run()); | ||
ElementNotIncludedInAnyViewsInspection elementNotIncludedInAnyViewsCheck = new ElementNotIncludedInAnyViewsInspection(workspace); | ||
OrphanedElementInspection orphanedElementCheck = new OrphanedElementInspection(workspace); | ||
for (Element element : workspace.getModel().getElements()) { | ||
add(elementNotIncludedInAnyViewsCheck.run(element)); | ||
add(orphanedElementCheck.run(element)); | ||
|
||
if (element instanceof Person) { | ||
add(new PersonDescriptionInspection(workspace).run(element)); | ||
} | ||
|
||
if (element instanceof SoftwareSystem) { | ||
add(new SoftwareSystemDescriptionInspection(workspace).run(element)); | ||
} | ||
|
||
if (element instanceof Container) { | ||
add(new ContainerDescriptionInspection(workspace).run(element)); | ||
add(new ContainerTechnologyInspection(workspace).run(element)); | ||
} | ||
|
||
if (element instanceof Component) { | ||
add(new ComponentDescriptionInspection(workspace).run(element)); | ||
add(new ComponentTechnologyInspection(workspace).run(element)); | ||
} | ||
} | ||
} | ||
|
||
private void runViewInspections(Workspace workspace) { | ||
add(new EmptyViewsInspection(workspace).run()); | ||
add(new SystemContextViewsForMultipleSoftwareSystemsInspection(workspace).run()); | ||
add(new ContainerViewsForMultipleSoftwareSystemsInspection(workspace).run()); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
structurizr-assistant/src/main/java/com/structurizr/assistant/Inspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.structurizr.assistant; | ||
|
||
import com.structurizr.PropertyHolder; | ||
import com.structurizr.Workspace; | ||
|
||
public abstract class Inspection { | ||
|
||
private static final String STRUCTURIZR_RECOMMENDATIONS_PREFIX = "structurizr.recommendations."; | ||
|
||
private final Workspace workspace; | ||
|
||
protected Inspection(Workspace workspace) { | ||
this.workspace = workspace; | ||
} | ||
|
||
protected abstract String getType(); | ||
|
||
protected Workspace getWorkspace() { | ||
return workspace; | ||
} | ||
|
||
protected boolean isEnabled(String type, PropertyHolder... propertyHolders) { | ||
String value = "true"; | ||
|
||
for (PropertyHolder propertyHolder : propertyHolders) { | ||
if (propertyHolder != null) { | ||
value = propertyHolder.getProperties().getOrDefault(STRUCTURIZR_RECOMMENDATIONS_PREFIX + type, value); | ||
} | ||
} | ||
|
||
return !value.equalsIgnoreCase("false"); | ||
} | ||
|
||
protected Recommendation noRecommendation() { | ||
return null; | ||
} | ||
|
||
protected Recommendation lowPriorityRecommendation(String description) { | ||
return new Recommendation(STRUCTURIZR_RECOMMENDATIONS_PREFIX + getType(), Priority.Low, description); | ||
} | ||
|
||
protected Recommendation mediumPriorityRecommendation(String description) { | ||
return new Recommendation(STRUCTURIZR_RECOMMENDATIONS_PREFIX + getType(), Priority.Medium, description); | ||
} | ||
|
||
protected Recommendation highPriorityRecommendation(String description) { | ||
return new Recommendation(STRUCTURIZR_RECOMMENDATIONS_PREFIX + getType(), Priority.High, description); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
structurizr-assistant/src/main/java/com/structurizr/assistant/Priority.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.structurizr.assistant; | ||
|
||
public enum Priority { | ||
|
||
Low, | ||
Medium, | ||
High | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
structurizr-assistant/src/main/java/com/structurizr/assistant/Recommendation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.structurizr.assistant; | ||
|
||
public final class Recommendation { | ||
|
||
private final String type; | ||
private final Priority priority; | ||
private final String description; | ||
|
||
Recommendation(String type, Priority priority, String description) { | ||
this.type = type; | ||
this.priority = priority; | ||
this.description = description; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public Priority getPriority() { | ||
return priority; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return type + " | " + priority + " | " + description; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...sistant/src/main/java/com/structurizr/assistant/model/ComponentDescriptionInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
|
||
public class ComponentDescriptionInspection extends ElementDescriptionInspection { | ||
|
||
public ComponentDescriptionInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected String getType() { | ||
return "model.component.description"; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
structurizr-assistant/src/main/java/com/structurizr/assistant/model/ComponentInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.assistant.Recommendation; | ||
import com.structurizr.model.Component; | ||
import com.structurizr.model.Element; | ||
|
||
abstract class ComponentInspection extends ElementInspection { | ||
|
||
public ComponentInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected Recommendation inspect(Element element) { | ||
return inspect((Component)element); | ||
} | ||
|
||
protected abstract Recommendation inspect(Component component); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ssistant/src/main/java/com/structurizr/assistant/model/ComponentTechnologyInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.assistant.Recommendation; | ||
import com.structurizr.model.Component; | ||
import com.structurizr.util.StringUtils; | ||
|
||
public class ComponentTechnologyInspection extends ComponentInspection { | ||
|
||
public ComponentTechnologyInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected Recommendation inspect(Component component) { | ||
if (StringUtils.isNullOrEmpty(component.getDescription())) { | ||
return lowPriorityRecommendation("Add a technology to the " + terminologyFor(component).toLowerCase() + " named \"" + component.getName() + "\"."); | ||
} | ||
|
||
return noRecommendation(); | ||
} | ||
|
||
@Override | ||
protected String getType() { | ||
return "model.component.technology"; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...sistant/src/main/java/com/structurizr/assistant/model/ContainerDescriptionInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
|
||
public class ContainerDescriptionInspection extends ElementDescriptionInspection { | ||
|
||
public ContainerDescriptionInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected String getType() { | ||
return "model.container.description"; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
structurizr-assistant/src/main/java/com/structurizr/assistant/model/ContainerInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.assistant.Recommendation; | ||
import com.structurizr.model.Container; | ||
import com.structurizr.model.Element; | ||
|
||
abstract class ContainerInspection extends ElementInspection { | ||
|
||
public ContainerInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected Recommendation inspect(Element element) { | ||
return inspect((Container)element); | ||
} | ||
|
||
protected abstract Recommendation inspect(Container container); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...ssistant/src/main/java/com/structurizr/assistant/model/ContainerTechnologyInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.assistant.Recommendation; | ||
import com.structurizr.model.Container; | ||
import com.structurizr.util.StringUtils; | ||
|
||
public class ContainerTechnologyInspection extends ContainerInspection { | ||
|
||
public ContainerTechnologyInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected Recommendation inspect(Container container) { | ||
if (StringUtils.isNullOrEmpty(container.getTechnology())) { | ||
return mediumPriorityRecommendation("Add a technology to the " + terminologyFor(container).toLowerCase() + " named \"" + container.getName() + "\"."); | ||
} | ||
|
||
return noRecommendation(); | ||
} | ||
|
||
@Override | ||
protected String getType() { | ||
return "model.container.technology"; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...nt/src/main/java/com/structurizr/assistant/model/DeploymentNodeDescriptionInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
|
||
public class DeploymentNodeDescriptionInspection extends ElementDescriptionInspection { | ||
|
||
public DeploymentNodeDescriptionInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected String getType() { | ||
return "model.deploymentnode.description"; | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...izr-assistant/src/main/java/com/structurizr/assistant/model/DeploymentNodeInspection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.structurizr.assistant.model; | ||
|
||
import com.structurizr.Workspace; | ||
import com.structurizr.assistant.Recommendation; | ||
import com.structurizr.model.DeploymentNode; | ||
import com.structurizr.model.Element; | ||
|
||
abstract class DeploymentNodeInspection extends ElementInspection { | ||
|
||
public DeploymentNodeInspection(Workspace workspace) { | ||
super(workspace); | ||
} | ||
|
||
@Override | ||
protected Recommendation inspect(Element element) { | ||
return inspect((DeploymentNode)element); | ||
} | ||
|
||
protected abstract Recommendation inspect(DeploymentNode deploymentNode); | ||
|
||
} |
Oops, something went wrong.