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

chore: convert qodana config to new format #5402

Merged
merged 16 commits into from
Aug 28, 2023
35 changes: 35 additions & 0 deletions .github/workflows/qodana-cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Workflow for testing spoon code quality.
#
# Note that actions are specified by commit hash. This is to avoid the security
# risk of someone injecting malicious code into a release and then simply
# changing a tag.

name: Qodana-Cloud-Scan
on:
workflow_dispatch:
pull_request:
push:
branches:
- master

permissions:
contents: read
jobs:
qodana:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@77f0ff0c702065648df9fd0340a48919dca5a1ff # v2023.2.1
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
- uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json

4 changes: 4 additions & 0 deletions .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
with:
args: --source-directory,./src/main/java , --fail-threshold, 0
post-pr-comment: "false"
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
- uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
Expand All @@ -37,6 +39,8 @@ jobs:
with:
args: --source-directory,./spoon-javadoc/src/main/java , --fail-threshold, 0
post-pr-comment: "false"
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
- uses: github/codeql-action/upload-sarif@a09933a12a80f87b87005513f0abb1494c27a716 # v2
with:
sarif_file: ${{ runner.temp }}/qodana/results/qodana.sarif.json
63 changes: 36 additions & 27 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
profile:
name: qodana.recommended
version: "1.0"
include:
- name: Anonymous2MethodRef
- name: AssignmentToCatchBlockParameter
- name: AssignmentToLambdaParameter
- name: AssignmentToMethodParameter
- name: AssignmentToNull
- name: Convert2Lambda
- name: DoubleBraceInitialization
- name: EqualsAndHashcode
- name: JavaLangImport
# Disabled for annotations applied to type
#- name: MissortedModifiers
- name: NestedAssignment
- name: NonShortCircuitBoolean
- name: RedundantFieldInitialization
- name: RedundantSuppression
- name: Reformat
- name: ReturnNull
- name: SamePackageImport
- name: StringEquality
- name: UnnecessaryBoxing
- name: UnnecessaryLocalVariable
- name: UnnecessaryUnboxing
- name: UNUSED_IMPORT
- name: PointlessBooleanExpression
exclude:
- name: UseOfClone
linter: jetbrains/qodana-jvm:2023.2
groups:
- groupId: IncludedPaths
groups:
- "category:Java"
- "GLOBAL"
- groupId: ExcludedInspections # list of inspections disabled by specific reason
inspections:
- "!IncludedPaths"
- Annotator # substituted by JavaAnnotator in sanity
- JavaAnnotator # works in "sanity" inspections
- SyntaxError # should work on sanity level
- Since15 # Detects wrong language level. Should work on sanity.
- JavadocBlankLines # Questionable. Spam on mockito, RxJava and other projects.
- UseOfClone # We often use clone (correctly implemented as a deep copy). It's not a problem.
- UnstableApiUsage
- MissortedModifiers # Disabled for annotations applied to type
inspections:
- group: ExcludedInspections
enabled: false
- group: IncludedPaths
ignore:
- "vendor/**"
- "build/**"
- "buildSrc/**"
- "builds/**"
- "dist/**"
- "tests/**"
- "tools/**"
- "vendor/**"
- "**.test.ts"
- "scope#$gitignore" # $gitignore scope available only in qodana execution
- "scope#test:*..*"
- "scope#file:buildSrc/*"
- inspection: JavadocReference
severity: WARNING # It has default ERROR severity. It's understandable for unresolved references in javadocs for editor but not on CI.
10 changes: 10 additions & 0 deletions src/main/java/spoon/support/reflect/code/CtInvocationImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,14 @@
public CtInvocation<T> clone() {
return (CtInvocation<T>) super.clone();
}


// just to test if qodana works
public void qodanaTest(String a) {
Integer[] arr = null;
arr.toString();

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Nullability and data flow problems

Method invocation `toString` will produce `NullPointerException`

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Result of method call ignored

Result of `Object.toString()` is ignored

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Call to 'toString()' on array

Call to 'toString()' on array

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Nullability and data flow problems

Method invocation `toString` will produce `NullPointerException`

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Result of method call ignored

Result of `Object.toString()` is ignored

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Call to 'toString()' on array

Call to 'toString()' on array

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

Nullability and data flow problems

Method invocation `toString` will produce `NullPointerException`

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

Result of method call ignored

Result of `Object.toString()` is ignored

Check warning on line 215 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

Call to 'toString()' on array

Call to 'toString()' on array
arr.hashCode();

Check warning on line 216 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

'hashCode()' called on array

`hashCode()` called on array should probably be 'Arrays.hashCode()'

Check warning on line 216 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Result of method call ignored

Result of `Object.hashCode()` is ignored

Check warning on line 216 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

'hashCode()' called on array

`hashCode()` called on array should probably be 'Arrays.hashCode()'

Check warning on line 216 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Result of method call ignored

Result of `Object.hashCode()` is ignored

Check warning on line 216 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

'hashCode()' called on array

`hashCode()` called on array should probably be 'Arrays.hashCode()'

Check warning on line 216 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

Result of method call ignored

Result of `Object.hashCode()` is ignored
a.equals(arr);

Check warning on line 217 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

'equals()' between objects of inconvertible types

`equals` between objects of inconvertible types 'String' and 'Integer\[\]'

Check warning on line 217 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Result of method call ignored

Result of `String.equals()` is ignored

Check warning on line 217 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

'equals()' between objects of inconvertible types

`equals` between objects of inconvertible types 'String' and 'Integer\[\]'

Check warning on line 217 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Result of method call ignored

Result of `String.equals()` is ignored

Check warning on line 217 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

'equals()' between objects of inconvertible types

`equals` between objects of inconvertible types 'String' and 'Integer\[\]'

Check warning on line 217 in src/main/java/spoon/support/reflect/code/CtInvocationImpl.java

View workflow job for this annotation

GitHub Actions / qodana

Result of method call ignored

Result of `String.equals()` is ignored
System.out.println(a);
}
}
Loading