Skip to content

Commit

Permalink
#88 Fix code smells
Browse files Browse the repository at this point in the history
Apply recommended code smell fixes
Deactivate Sonar analysis for test plugin

Change-Id: I0000000000000000000000000000000000000000
Signed-off-by: Arnaud Dieumegard <arnaud.dieumegard@obeo.fr>
  • Loading branch information
arnauddieumegard authored and pdulth committed Jun 10, 2022
1 parent 94426ba commit 403ae25
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 193 deletions.
Original file line number Diff line number Diff line change
@@ -1,76 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2019 THALES GLOBAL SERVICES.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0
SPDX-License-Identifier: EPL-2.0
Contributors:
Thales - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.polarsys</groupId>
<artifactId>org.polarsys.capella.addon.transition.system2subsystem</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<artifactId>org.polarsys.capella.transition.system2subsystem.tests.ju</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>1.6.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<product>${capella-product-id}</product>
<application>${capella-application}</application>
<useUIHarness>true</useUIHarness>
<useUIThread>true</useUIThread>
<testClass>org.polarsys.capella.transition.system2subsystem.tests.AllSystem2SubsystemTests</testClass>
<dependencies>
<!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=462862 -->
<dependency>
<type>eclipse-plugin</type>
<artifactId>org.eclipse.equinox.event</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<environments combine.self="override"/>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-feature</type>
<id>org.polarsys.capella.rcp</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-feature</type>
<id>org.polarsys.capella.transition.system2subsystem.feature</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2017, 2019 THALES GLOBAL SERVICES.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0
SPDX-License-Identifier: EPL-2.0
Contributors:
Thales - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.polarsys</groupId>
<artifactId>org.polarsys.capella.addon.transition.system2subsystem</artifactId>
<version>1.6.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<properties>
<!-- Skip test plugin in Sonar analysis -->
<sonar.skip>true</sonar.skip>
</properties>

<artifactId>org.polarsys.capella.transition.system2subsystem.tests.ju</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>1.6.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<product>${capella-product-id}</product>
<application>${capella-application}</application>
<useUIHarness>true</useUIHarness>
<useUIThread>true</useUIThread>
<testClass>org.polarsys.capella.transition.system2subsystem.tests.AllSystem2SubsystemTests</testClass>
<dependencies>
<!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=462862 -->
<dependency>
<type>eclipse-plugin</type>
<artifactId>org.eclipse.equinox.event</artifactId>
<version>0.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<environments combine.self="override"/>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-feature</type>
<id>org.polarsys.capella.rcp</id>
<versionRange>0.0.0</versionRange>
</requirement>
<requirement>
<type>eclipse-feature</type>
<id>org.polarsys.capella.transition.system2subsystem.feature</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class CopyImagesTest {

private static final String COPIED_IMAGE_PATH = "images/Capella128x128.png";

// Hide default constructor
CopyImagesTest() {}

/**
* Test that verifies the copy of images during a Multiphases transition
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class CopyImagesActivity extends AbstractActivity {
* {@inheritDoc}
*/
@Override
protected IStatus _run(ActivityParameters activityParams_p) {
protected IStatus _run(ActivityParameters activityParams) {

IContext transformationContext = getContext(activityParams_p);
IContext transformationContext = getContext(activityParams);
Project sourceProject = ContextHelper.getSourceProject(transformationContext);
Project targetProject = ContextHelper.getTargetProject(transformationContext);

Expand Down Expand Up @@ -78,7 +78,7 @@ private void copyImagesToTargetProject(IProject sourceEclipseProject, IProject t
}
} catch (CoreException e) {
LogHelper.getInstance().log(e.getMessage(), new Status(IStatus.ERROR, org.polarsys.capella.transition.system2subsystem.Activator.PLUGIN_ID, e.getMessage(), e),
Messages.Activity_CopyImages);
Messages.activityCopyImages);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Messages extends NLS {
public static String Rule_InteractionState_FailMsg;
public static String Rule_StateFragment_FailMsg;
public static String Rule_InteractionFunctionState_FailMsg;
public static String Activity_CopyImages;
public static String activityCopyImages;

static {
// initialize resource bundle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Rule_InteractionState_FailMsg=An interaction state is never transitioned between
Rule_InteractionFunctionState_FailMsg=An interaction state with a function cannot be transitioned while exchange scenario to interface scenario.
Rule_StateFragment_FailMsg=A state fragment is never transitioned between two different phases.

Activity_CopyImages=CopyImages
activityCopyImages=CopyImages
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.polarsys.capella.core.model.helpers.BlockArchitectureExt;
import org.polarsys.capella.core.model.helpers.FunctionalChainExt;
import org.polarsys.capella.core.model.helpers.graph.InvolvementHierarchyGraph;
import org.polarsys.capella.core.model.helpers.graph.InvolvementHierarchyGraph.Edge;
import org.polarsys.capella.core.model.helpers.graph.InvolvementHierarchyGraph.Element;
import org.polarsys.capella.core.model.helpers.graph.InvolvementHierarchyGraph.Vertex;
import org.polarsys.capella.core.transition.common.constants.ITransitionConstants;
Expand Down Expand Up @@ -80,17 +79,17 @@ public static FunctionalChainAttachmentHelper getInstance(IContext context_p) {
return handler;
}

public HashMap<FunctionalChain, InvolvementHierarchyGraph> getGraphs(IContext context_p) {
HashMap<FunctionalChain, InvolvementHierarchyGraph> graphs = (HashMap) context_p.get(GRAPH_MAPS);
public Map<FunctionalChain, InvolvementHierarchyGraph> getGraphs(IContext context) {
HashMap<FunctionalChain, InvolvementHierarchyGraph> graphs = (HashMap) context.get(GRAPH_MAPS);
if (graphs == null) {
graphs = new HashMap<FunctionalChain, InvolvementHierarchyGraph>();
context_p.put(GRAPH_MAPS, graphs);
graphs = new HashMap<>();
context.put(GRAPH_MAPS, graphs);
}
return graphs;
}

public InvolvementHierarchyGraph getGraph(FunctionalChain chain, IContext context_p) {
HashMap<FunctionalChain, InvolvementHierarchyGraph> graphs = getGraphs(context_p);
public InvolvementHierarchyGraph getGraph(FunctionalChain chain, IContext context) {
Map<FunctionalChain, InvolvementHierarchyGraph> graphs = getGraphs(context);
if (!graphs.containsKey(chain)) {
graphs.put(chain, new InvolvementHierarchyGraph(chain));
}
Expand Down

0 comments on commit 403ae25

Please sign in to comment.