Skip to content

Commit

Permalink
💚 add QODANA #23
Browse files Browse the repository at this point in the history
  • Loading branch information
trydofor committed Feb 17, 2024
1 parent 091ce7f commit ce6f8a8
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 50 deletions.
59 changes: 47 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ on:
default: false
type: boolean
required: false
testCoverageDryRun:
description: 'dryrun coverage report?'
default: false
type: boolean
required: false
testVerbose:
description: 'test output verbose'
default: false
type: boolean
required: false
applyQodanaScan:
description: 'apply Qodana Scan?'
default: true
type: boolean
required: false
deployOssrh:
description: 'deploy to ossrh?'
default: true
Expand All @@ -33,9 +43,13 @@ jobs:
release:
name: Release to Sonatype
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
env:
MAVEN_OPTS: -Xmx2g
TEST_VERBOSE: ${{ inputs.testVerbose }}
TEST_VERBOSE: ${{ inputs.testVerbose == 'true' }}

steps:
- name: Checkout ${{ github.event.release.tag_name }}
Expand Down Expand Up @@ -63,31 +77,43 @@ jobs:
- name: Maven settings.xml
id: settings
run: |
echo "# env and var" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
JAVA_HOME=$(asdf where java)
echo "- JAVA_HOME=$JAVA_HOME" >> "$GITHUB_STEP_SUMMARY"
echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_OUTPUT"
echo "- GIT_BRANCH=$(git branch --show-current)" >> "$GITHUB_STEP_SUMMARY"
echo "GIT_BRANCH=$(git branch --show-current)" >> "$GITHUB_OUTPUT"
_opt=$(git describe --tags --exact-match 2>/dev/null || true)
if [ "$_opt" != "" ]; then
_opt="-Drevision=$_opt"
echo "MVN_REVISION=$_opt"
echo "- MVN_REVISION=$_opt" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_REVISION=$_opt" >> "$GITHUB_OUTPUT"
fi
_ver=$(mvn --quiet --non-recursive -DforceStdout -Dexpression=project.version $_opt help:evaluate)
echo "WINGS_VERSION=$_ver"
echo "- WINGS_VERSION=$_ver" >> "$GITHUB_STEP_SUMMARY"
echo "WINGS_VERSION=$_ver" >> "$GITHUB_OUTPUT"
_cov=${{ inputs.testCoverReport || github.event_name == 'push' }}
echo "MVN_COVERAGE=$_cov"
echo "- MVN_COVERAGE=$_cov" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_COVERAGE=$_cov" >> "$GITHUB_OUTPUT"
_drh=${{ inputs.deployOssrh || github.event_name == 'release' }}
echo "MVN_DEPLOYRH=$_drh"
echo "- MVN_DEPLOYRH=$_drh" >> "$GITHUB_STEP_SUMMARY"
echo "MVN_DEPLOYRH=$_drh" >> "$GITHUB_OUTPUT"
mvn -v
git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s'
_qod=${{ inputs.applyQodanaScan || 'false' }}
echo "- QODANA_SCAN=$_qod" >> "$GITHUB_STEP_SUMMARY"
echo "QODANA_SCAN=$_qod" >> "$GITHUB_OUTPUT"
echo "# mvn and git" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo '```text' >> "$GITHUB_STEP_SUMMARY"
mvn -v >> "$GITHUB_STEP_SUMMARY"
git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s' >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << "EOF"
Expand All @@ -102,18 +128,27 @@ jobs:
</servers>
</settings>
EOF
- name: Qodana Scan
uses: JetBrains/[email protected]
if: steps.settings.outputs.QODANA_SCAN == 'true'
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
## report if not release
- name: Test Coverage ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: steps.settings.outputs.MVN_COVERAGE == 'true'
run: >
mvn
-P coverage
-Dmaven.test.failure.ignore=${{ inputs.testFailureIgnore }}
-DrepoToken=${{ secrets.COVERALLS_REPO_TOKEN }}
-P 'coverage'
-Dmaven.test.failure.ignore=$TESTFAILS_IGNORE
-DrepoToken=$COVERALLS_WINGS -DdryRun=$COVERALLS_DRYRUN
clean test jacoco:report coveralls:report
env:
TZ: Asia/Shanghai
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
COVERALLS_WINGS: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_DRYRUN: ${{ inputs.testCoverageDryRun || 'false' }}
TESTFAILS_IGNORE: ${{ inputs.testFailureIgnore || 'false' }}

## import gpp private key
- name: Import GPG key
if: steps.settings.outputs.MVN_DEPLOYRH == 'true'
Expand All @@ -127,7 +162,7 @@ jobs:
if: steps.settings.outputs.MVN_DEPLOYRH == 'true'
run: >
mvn
-P ossrh
-P 'ossrh'
${{ steps.settings.outputs.MVN_REVISION }}
-Dgpg.passphrase=${MVN_GPG_PASS}
clean deploy
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/pro/fessional/mirana/best/DummyBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public static void ignore(Throwable t) {
/**
* statement has empty body
*/
@SuppressWarnings("EmptyMethod")
public static void empty() {
// ignore, need empty
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/pro/fessional/mirana/best/TypedKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TypedReg)) return false;
TypedReg<?, ?> reg = (TypedReg<?, ?>) o;
//noinspection EqualsBetweenInconvertibleTypes
return Objects.equals(regType, reg.regType);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/pro/fessional/mirana/bits/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public static int unicode(char c, byte[] ob) {
if (ob == null) return 0;

if (c > Byte.MAX_VALUE) {
//noinspection UnnecessaryLocalVariable
final int i = c;
ob[0] = '\\';
ob[1] = 'u';
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/pro/fessional/mirana/code/SlotCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class SlotCode {
}

public final int size;
private final int last;
private final Slot[] slot;
private final Random rand;

Expand All @@ -49,7 +48,7 @@ public SlotCode(int size, Supplier<Random> rand) {
public SlotCode(int size, Random rand) {
final int page = (size - 1) / bits + 1;
this.size = size;
this.last = (1 << (bits - size % bits)) - 1;
int last = (1 << (bits - size % bits)) - 1;
this.rand = rand;
this.slot = new Slot[page];
for (int i = 0; i < page; i++) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/pro/fessional/mirana/cond/EqualsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static boolean inVal(Number a, Number[] nums) {
public static boolean inVal(Number a, Number b, Number... nums) {
if (a == null || b == null || nums == null) return false;
final boolean e = eqVal(a, b);
return e ? e : inVal(a, Arrays.asList(nums));
return e || inVal(a, Arrays.asList(nums));

}

Expand Down Expand Up @@ -133,7 +133,7 @@ public static boolean inCase(String a, CharSequence[] strs) {
public static boolean inCase(String a, CharSequence b, CharSequence... strs) {
if (a == null || b == null || strs == null) return false;
final boolean e = eqCase(a, b);
return e ? e : inCase(a, Arrays.asList(strs));
return e || inCase(a, Arrays.asList(strs));
}

public static boolean inCase(String a, Iterable<? extends CharSequence> strs) {
Expand All @@ -159,7 +159,7 @@ public static boolean inCaseless(String a, CharSequence[] strs) {
public static boolean inCaseless(String a, CharSequence b, CharSequence... strs) {
if (a == null || b == null || strs == null) return false;
final boolean e = eqCaseless(a, b);
return e ? e : inCaseless(a, Arrays.asList(strs));
return e || inCaseless(a, Arrays.asList(strs));
}

public static boolean inCaseless(String a, Iterable<? extends CharSequence> strs) {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/pro/fessional/mirana/data/Arr.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static byte[] set(byte[] arr, int idx, byte v) {
return arr;
}
else {
byte[] tmp = new byte[Math.max(idx, arr.length) + 1];
byte[] tmp = new byte[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -83,7 +83,7 @@ public static short[] set(short[] arr, int idx, short v) {
return arr;
}
else {
short[] tmp = new short[Math.max(idx, arr.length) + 1];
short[] tmp = new short[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -97,7 +97,7 @@ public static char[] set(char[] arr, int idx, char v) {
return arr;
}
else {
char[] tmp = new char[Math.max(idx, arr.length) + 1];
char[] tmp = new char[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -111,7 +111,7 @@ public static int[] set(int[] arr, int idx, int v) {
return arr;
}
else {
int[] tmp = new int[Math.max(idx, arr.length) + 1];
int[] tmp = new int[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -125,7 +125,7 @@ public static long[] set(long[] arr, int idx, long v) {
return arr;
}
else {
long[] tmp = new long[Math.max(idx, arr.length) + 1];
long[] tmp = new long[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -139,7 +139,7 @@ public static float[] set(float[] arr, int idx, float v) {
return arr;
}
else {
float[] tmp = new float[Math.max(idx, arr.length) + 1];
float[] tmp = new float[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -153,7 +153,7 @@ public static double[] set(double[] arr, int idx, double v) {
return arr;
}
else {
double[] tmp = new double[Math.max(idx, arr.length) + 1];
double[] tmp = new double[idx + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pro/fessional/mirana/data/DataResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ default boolean isSuccess() {
*/
default boolean hasMessage() {
String msg = getMessage();
return msg != null && msg.length() > 0;
return msg != null && !msg.isEmpty();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/pro/fessional/mirana/data/Z.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static BigDecimal decimalSafe(BigDecimal d, Iterable<? extends CharSequence> ts)
for (CharSequence t : ts) {
if (t != null && t.length() > 0) {
String s = t.toString().trim();
if (s.length() > 0) {
if (!s.isEmpty()) {
try {
return new BigDecimal(s);
}
Expand Down Expand Up @@ -177,7 +177,7 @@ static Long int64Safe(Long d, Iterable<? extends CharSequence> ts) {
for (CharSequence t : ts) {
if (t != null && t.length() > 0) {
String s = t.toString().trim();
if (s.length() > 0) {
if (!s.isEmpty()) {
try {
return Long.valueOf(s);
}
Expand Down Expand Up @@ -215,7 +215,7 @@ static Integer int32Safe(Integer d, Iterable<? extends CharSequence> ts) {
for (CharSequence t : ts) {
if (t != null && t.length() > 0) {
String s = t.toString().trim();
if (s.length() > 0) {
if (!s.isEmpty()) {
try {
return Integer.valueOf(s);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ static String notBlankSafe(String d, Iterable<? extends CharSequence> ts) {
for (CharSequence t : ts) {
if (t != null && t.length() > 0) {
String s = t.toString().trim();
if (s.length() > 0) return s;
if (!s.isEmpty()) return s;
}
}
return d;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/pro/fessional/mirana/func/Clz.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ else if (c == '[') { // Array
if (p < 0) throw new RuntimeException("Invalid signature: " + signature);
list.add(Class.forName(signature.substring(i, p + 1).replace('/', '.')));
i = p;
break;
}
else {
list.add(Class.forName(signature.substring(i, Math.min(j + 1, len))));
i = j;
break;
}
break;
}
}
else if (c == 'B') list.add(byte.class);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/pro/fessional/mirana/i18n/I18nString.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String getI18n() {

@Contract("_ -> this")
public I18nString setHint(String hint) {
this.hint = hint == null ? "" : hint;;
this.hint = hint == null ? "" : hint;
return this;
}

Expand Down Expand Up @@ -114,8 +114,8 @@ public String getI18nHint() {

@Override
public String toString() {
if (i18n != null && i18n.length() > 0) return i18n;
if (hint != null && hint.length() > 0) return hint;
if (i18n != null && !i18n.isEmpty()) return i18n;
if (hint != null && !hint.isEmpty()) return hint;
return code;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,15 @@ public boolean setMinCount(int n) {

/**
* Whether to preload a fixed count of ids.
* fixed if greater than zero, dynamic otherwise
* fixed if ge FIX_COUNT, dynamic otherwise
*
* @param n count, Fixed count if greater than 0
* @param n count, Fixed count if ge FIX_COUNT
* @return success or not
* @see #FIX_COUNT
*/
public boolean setFixCount(int n) {
if (n < FIX_COUNT) return false;

loadFixCount = n;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/pro/fessional/mirana/page/PageResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public PageResult<E> addData(E e) {

@Contract("_->this")
public PageResult<E> addData(Collection<E> ds) {
if (ds != null && ds.size() > 0) {
if (ds != null && !ds.isEmpty()) {
Collection<E> data = getData();
if (data == empty) {
data = new ArrayList<>(size > 0 ? size : 20);
Expand All @@ -250,7 +250,7 @@ public PageResult<E> addData(Collection<E> ds) {
@Override
public boolean hasData() {
final Collection<E> data = getData();
return data.size() > 0;
return !data.isEmpty();
}

@NotNull
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pro/fessional/mirana/page/PageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Sb(StringBuilder sb) {

@Contract("_,_->this")
public Sb by(String key, boolean asc) {
if (key != null && key.length() > 0) {
if (key != null && !key.isEmpty()) {
buf.append(SORT_DELI);
if (!asc) buf.append(SORT_DESC);
buf.append(key);
Expand Down
Loading

0 comments on commit ce6f8a8

Please sign in to comment.