Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing IDE Versions and fixing qodana warnings #20

Merged
Merged
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
30 changes: 0 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,6 @@ jobs:
run: ./gradlew verifyPlugin
if: always()

qodana:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: install tree
run: sudo apt update && sudo apt install tree -y

- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}

- name: Download build artifact
uses: actions/download-artifact@v3

- name: Qodana Scan
uses: JetBrains/qodana-action@v2022.1.1
with:
cache-dir: ".qodana"
results-dir: "build/reports/inspections"

- name: Upload scan result
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json

verify-plugin-build:
runs-on: ubuntu-latest
needs:
Expand Down
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ repositories {

dependencies {
implementation("com.google.code.gson:gson:2.9.0")
implementation("com.fasterxml.jackson.core:jackson-core:2.13.1")
implementation("com.fasterxml.jackson.core:jackson-core:2.13.3")
implementation("com.googlecode.json-simple:json-simple:1.1.1")
implementation("com.jayway.jsonpath:json-path:2.7.0") {
exclude("org.slf4j", "slf4j-api")
Expand All @@ -41,7 +41,7 @@ dependencies {
implementation("io.pebbletemplates:pebble:3.1.5") {
exclude("org.slf4j", "slf4j-api")
}
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.20.0")
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
Expand Down Expand Up @@ -128,6 +128,10 @@ tasks {
jvmArgs("-Xmx2024m", "-Xms512m", "-XX:MaxPermSize=500m", "-ea")
}

runIdePerformanceTest {
testDataDir.set(projectDir.resolve("src/test").canonicalPath)
}

signPlugin {
if (System.getenv("CHAIN_CERT").isNullOrEmpty()) {
certificateChain.set(File(".ssl-keys/chain.crt").readText(Charsets.UTF_8))
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pluginUntilBuild = 222.*
# pluginUntilBuild = 221.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions
pluginVerifierIdeVersions = 2022.1.3, 2020.1.4, 2020.2.3, 2020.3, 2021.3.2, 2021.3.3, 2022.2
pluginVerifierIdeVersions = 2020.1.4, 2020.2.3, 2020.3, 2021.1, 2021.2, 2021.3, 2021.3.1, 2021.3.2, 2021.3.3, 2022.1, 2022.1.1, 2022.1.2, 2022.1.3, 2022.2

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IU
Expand Down
9 changes: 9 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
version: 1.0
profile:
name: qodana.recommended
exclude:
- name: All
paths:
- .qodana
- build
- .gradle
- .github
include:
- name: CheckDependencyLicenses
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CreateFileFromTemplateAction(
}

@Override
public void actionPerformed(AnActionEvent e)
public void actionPerformed(@NotNull AnActionEvent e)
{

final IdeView view = getIdeView(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private void writeMethodFromTemplate(String templatePathString) throws IOExcepti
if(psiFile.isWritable())
{

assert phpClass != null;
PsiElement method = PhpCodeUtil.createMethodFromTemplate(phpClass, proj, finalMethodString);
if (method == null) {
return;
Expand All @@ -152,8 +151,8 @@ private void writeMethodFromTemplate(String templatePathString) throws IOExcepti

private int getMethodInsertPosition(PhpClass phpClass) {
int insertPos = -1;

int methodEndPos = -1;

PsiElement method = PsiTreeUtil.findChildOfType(phpClass, Method.class);
if (method != null) {
methodEndPos = method.getTextRange().getEndOffset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void invokeDialog(@NotNull Project project, @NotNull PsiDirectory dire
validator
);

if (moduleName == null || moduleName.equals("")) {
if (moduleName == null || moduleName.isEmpty()) {
return;
}
elementsConsumer.accept(validator.getCreatedElements());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {

/// Using the event, create and show a dialog
Project currentProject = event.getProject();
StringBuffer dlgMsg = new StringBuffer(event.getPresentation().getText() + " Selected!");
StringBuilder dlgMsg = new StringBuilder(event.getPresentation().getText() + " Selected!");
String dlgTitle = event.getPresentation().getDescription();
// If an element is selected in the editor, add info about it.
Navigatable nav = event.getData(CommonDataKeys.NAVIGATABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public JComponent getPreferredFocusedComponent() {
@Override
public @Nullable JComponent createComponent() {
ApplicationSettingsState settings = ApplicationSettingsState.getInstance();
if (settings == null) {
throw new RuntimeException("Settings isn't accessible.");
}

applicationSettingsComponent = new ApplicationSettingsComponent();
applicationSettingsComponent.setProjectNamespaceTextText(settings.projectNamespace);
return applicationSettingsComponent.getPanel();
Expand All @@ -35,18 +39,30 @@ public JComponent getPreferredFocusedComponent() {
@Override
public boolean isModified() {
ApplicationSettingsState settings = ApplicationSettingsState.getInstance();
if (settings == null) {
throw new RuntimeException("Settings isn't accessible.");
}

return !applicationSettingsComponent.getProjectNamespaceText().equals(settings.projectNamespace);
}

@Override
public void apply() {
ApplicationSettingsState settings = ApplicationSettingsState.getInstance();
if (settings == null) {
throw new RuntimeException("Settings isn't accessible.");
}

settings.projectNamespace = applicationSettingsComponent.getProjectNamespaceText();
}

@Override
public void reset() {
ApplicationSettingsState settings = ApplicationSettingsState.getInstance();
if (settings == null) {
throw new RuntimeException("Settings isn't accessible.");
}

applicationSettingsComponent.setProjectNamespaceTextText(settings.projectNamespace);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static ApplicationSettingsState getInstance() {
if (ApplicationManager.getApplication() != null) {
return ApplicationManager.getApplication().getService(ApplicationSettingsState.class);
}

return null;
}
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ public String getResultFileNameFromTemplateNameAndContext(String templateName, C

private String getResultFileNameForValidationOrCodeCeption(String templateName, Context context) {
if (templateName.toLowerCase().contains("validation") ) {
return "" + new UnderscoredFilter().apply(context.getModuleName(), null, null, null, 0)
+ "."
+ templateName.toLowerCase().replace(".twig", "");
return String.format("%s.%s", new UnderscoredFilter().apply(context.getModuleName(), null, null, null, 0), templateName.toLowerCase().replace(".twig", ""));
}

return "" + templateName.replace(".twig", "");
return String.format("%s", templateName.replace(".twig", ""));
}

private String getResultFileNameForPhp(String templateName, Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class TwigResources implements TwigResourcesInterface {
private final Map<String, ArrayList<TwigTreeNode>> map = new HashMap<>();


private final String twigResourcesTreePath = "template-map.json";
private final String FILE_NODE_TYPE = "file";
private final static String twigResourcesTreePath = "template-map.json";
public final static String DIRECTORY_NODE_TYPE = "directory";

protected static TwigResources instance = null;
Expand Down