Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2.4.0
uses: actions/checkout@v4

# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1.0.4
uses: gradle/actions/wrapper-validation@v3

# Setup Java 11 environment for the next steps
# Setup Java 17 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17
cache: gradle

# Set environment variables
Expand Down Expand Up @@ -76,14 +76,14 @@ jobs:
# Collect Tests Result of failed tests
- name: Collect Tests Result
if: ${{ failure() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: tests-result
path: ${{ github.workspace }}/build/reports/tests

# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
uses: actions/cache@v2.1.6
uses: actions/cache@v4
with:
path: ${{ steps.properties.outputs.pluginVerifierHomeDir }}/ides
key: plugin-verifier-${{ hashFiles('build/listProductsReleases.txt') }}
Expand All @@ -95,7 +95,7 @@ jobs:
# Collect Plugin Verifier Result
- name: Collect Plugin Verifier Result
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: pluginVerifier-result
path: ${{ github.workspace }}/build/reports/pluginVerifier
Expand All @@ -117,7 +117,7 @@ jobs:

# Store already-built plugin as an artifact for downloading
- name: Upload artifact
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact.outputs.filename }}
path: ./build/distributions/content/*/*
Expand All @@ -133,7 +133,7 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2.4.0
uses: actions/checkout@v4

# Remove old release drafts by using the curl request for the available releases with draft flag
- name: Remove Old Release Drafts
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2.4.0
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

# Setup Java 11 environment for the next steps
# Setup Java 17 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17
cache: gradle

# Set environment variables
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v2.4.0
uses: actions/checkout@v4

# Setup Java 11 environment for the next steps
# Setup Java 17 environment for the next steps
- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17
cache: gradle

# Run IDEA prepared for UI testing
Expand Down
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.6.0"
id("org.jetbrains.kotlin.jvm") version "1.7.20"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.13.1"
id("org.jetbrains.intellij") version "1.17.4"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "2.0.0"
// Gradle Qodana Plugin
Expand Down Expand Up @@ -103,7 +103,7 @@
runIde {
//project property paths is set in the command line script
if(project.hasProperty("paths")) {
args("tsdetect", project.properties.get("paths"))

Check notice on line 106 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / Qodana

Explicit 'get' or 'set' call

Explicit 'get' call
jvmArgs("-Djava.awt.headless=true")
}
}
Expand All @@ -129,7 +129,9 @@
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first()))
val pluginVer = project.findProperty("pluginVersion") as String
val label = if (pluginVer.contains('-')) pluginVer.split('-')[1].split('.')[0] else "default"
channels.set(listOf(label))
}

}
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
pluginGroup = org.scanl
pluginName = TSDetect
# SemVer format -> https://semver.org
pluginVersion = 0.0.2
pluginVersion = 0.0.3

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 203
pluginUntilBuild = 223.*
pluginSinceBuild = 223
pluginUntilBuild = 241.*

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IC
platformVersion = 2021.3.3
platformVersion = 2022.3.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = java

# Java language level used to compile sources and to generate the files for - Java 11 is required since 2020.3
javaVersion = 11
javaVersion = 17

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.3
gradleVersion = 8.5
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions src/main/java/org/scanl/plugins/tsdetect/SmellVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
private final Logger logger = LogManager.getLogger(this.getClass());
private final List<InspectionMethodModel> psiMethods = new ArrayList<>();
private final List<InspectionClassModel> psiClasses = new ArrayList<>();
private List<String> smellyClasses = new ArrayList<>();

Check warning on line 25 in src/main/java/org/scanl/plugins/tsdetect/SmellVisitor.java

View workflow job for this annotation

GitHub Actions / Qodana

Field may be 'final'

Field `smellyClasses` may be 'final'
private final TestSmellInspectionProvider provider = new TestSmellInspectionProvider();

@Override
public void visitClass(PsiClass cls){

Check warning on line 29 in src/main/java/org/scanl/plugins/tsdetect/SmellVisitor.java

View workflow job for this annotation

GitHub Actions / Qodana

@NotNull/@Nullable problems

Not annotated parameter overrides @NotNull parameter

Class<? extends LocalInspectionTool> @NotNull [] classes = provider.getInspectionClasses(); //gets the list of smells to check for
List<SmellInspection> inspections = new ArrayList<>();

for(Class<? extends LocalInspectionTool> c : classes){ //converts from .class files into SmellInspection objects
try {
SmellInspection a = (SmellInspection) c.newInstance();
SmellInspection a = (SmellInspection) c.getDeclaredConstructor().newInstance();
inspections.add(a);
} catch (InstantiationException | IllegalAccessException e) {
} catch (Exception e) {
logger.error(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.intellij.psi.util.MethodSignature;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.ui.DocumentAdapter;
import com.intellij.util.indexing.FileBasedIndex;

Check warning on line 18 in src/main/java/org/scanl/plugins/tsdetect/inspections/SmellInspection.java

View workflow job for this annotation

GitHub Actions / Qodana

Unused import

Unused import `import com.intellij.util.indexing.FileBasedIndex;`
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -60,23 +60,15 @@
* @return A boolean indicating whether the inspection should be ran.
*/
protected boolean shouldTestElement(PsiElement element) {
//TODO current workaround to get headless to run, will investigate the issue and fix before merge
try{
if (!PluginSettings.GetSetting(getSmellType().toString())) return false;
} catch (ExceptionInInitializerError e) {
//System.out.println("Project settings not initialised, project is likely being run in Headless mode \n" +
// "If that is not the case please ensure project settings are being initialized properly");
} catch (ExceptionInInitializerError | NoClassDefFoundError | RuntimeException ignored) {
}

PsiMethod psiMethod = element instanceof PsiMethod ? (PsiMethod) element : PsiTreeUtil.getParentOfType(element, PsiMethod.class);
if (psiMethod != null)
return JUnitUtil.isTestMethod(new PsiLocation<>(psiMethod));

if(element instanceof PsiMethod) {
psiMethod = (PsiMethod) element;
return JUnitUtil.isTestMethod(new PsiLocation<>(psiMethod));
}

PsiClass psiClass = element instanceof PsiClass ? (PsiClass) element : PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass == null) return false;

Expand Down Expand Up @@ -208,8 +200,8 @@

/**
* Gets all method calls made within a method
* @param method

Check warning on line 203 in src/main/java/org/scanl/plugins/tsdetect/inspections/SmellInspection.java

View workflow job for this annotation

GitHub Actions / Qodana

Javadoc declaration problems

`@param method` tag description is missing
* @return

Check warning on line 204 in src/main/java/org/scanl/plugins/tsdetect/inspections/SmellInspection.java

View workflow job for this annotation

GitHub Actions / Qodana

Javadoc declaration problems

`@return` tag description is missing
*/
static List<PsiMethodCallExpression> getMethodExpressions(PsiMethod method){
List<PsiMethodCallExpression> methodCallExpressionList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TabbedPaneWindowFactory implements ToolWindowFactory {
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
SmellTabbedPaneWindow myToolWindow = new SmellTabbedPaneWindow();
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
ContentFactory contentFactory = ContentFactory.getInstance();
Content content = contentFactory.createContent(myToolWindow.getContent(), "", false);
toolWindow.getContentManager().addContent(content);
//Method loaded here to ensure the user is prompted before the tool is run, without showing the popup multiple times
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/scanl/plugins/tsdetect/InspectionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.scanl.plugins.tsdetect;

import com.intellij.execution.PsiLocation;
import com.intellij.execution.junit.JUnitUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
Expand Down Expand Up @@ -27,6 +28,7 @@ public void setUp() throws Exception {
junitUtil = Mockito.mockStatic(JUnitUtil.class);
junitUtil.when(() -> JUnitUtil.isTestClass(Mockito.any(PsiClass.class))).thenReturn(true);
junitUtil.when(() -> JUnitUtil.isTestClass(Mockito.argThat(c -> c.getName().equals("TestClass")))).thenReturn(false);
junitUtil.when(() -> JUnitUtil.isTestMethod(Mockito.any(PsiLocation.class))).thenReturn(true);
}

@Override
Expand Down
Loading