Skip to content

Commit

Permalink
Feat/sonarqube (#876)
Browse files Browse the repository at this point in the history
* refactor: fixed warning by sonarqube

* chore: remove duplicate code

* add sonarcloud workflow

* refactor: rename package identifier to prevent potential conflicts

* chore: remove duplicate code

* refactor: use optional chain expression to more readable

* config: update exclusions for sonar

* refactor: reduce Cognitive Complexity

* chore: add func assert

* chore: split complex logic to function

* refactor: reduce Cognitive Complexity

* refactor: split code to func to reduce Cognitive Complexity

* refactor: split code to func to reduce Cognitive Complexity

* style: remove redundant comment in css

* style: remove redundant comment in css

* style: remove redundant comment in css

* sonar: update sonar rules

* chore: remove comment

* sonar: update sonar rules

* sonar: update sonar rules

* sonar: update sonar rules

* sonar: update sonar rules

* sonar: update sonar rules

* style: remove empty block

* sonar: update sonar rules

* sonar: fixed medium issues

* sonar: update sonar rules

* style: remove empty block

---------

Co-authored-by: phutx <[email protected]>
  • Loading branch information
trungbach and phutxorai authored Jul 22, 2024
1 parent 2bcfd73 commit 3c6f29e
Show file tree
Hide file tree
Showing 130 changed files with 1,068 additions and 1,823 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/reuseable-sonar.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Reuseable Sonaqube

on:
workflow_call:
workflow_dispatch:
pull_request:
push:
branches:
- 'feat/sonarqube'

jobs:
scan-repository:
name: scan repository with Sonaqube
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: sonarsource/sonarqube-scan-action@master
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
32 changes: 5 additions & 27 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// @ts-nocheck
import { TextEncoder, TextDecoder } from "util";
import { randomFillSync } from "crypto";
import type { Config } from "jest";
import { TextEncoder, TextDecoder } from 'util';
import { randomFillSync } from 'crypto';

// polyfill for jest crypto function (because of Injective ts sdk)
window.crypto = {
getRandomValues(buffer) {
return randomFillSync(buffer);
},
}
};

// polyfill for jest formatToJson function
Expand All @@ -16,31 +15,10 @@ Intl.DateTimeFormat.prototype.formatToJson = function (date: Date) {
return Object.fromEntries(
_this
.formatToParts(date)
.filter((item) => item.type !== "literal")
.map((item) => [item.type, item.value]),
.filter((item) => item.type !== 'literal')
.map((item) => [item.type, item.value])
) as Record<Intl.DateTimeFormatPartTypes, string>;
};

global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

// const config: Config = {
// preset: "ts-jest/presets/js-with-ts",
// testEnvironment: "node",
// globals: {
// "ts-jest": {
// tsconfig: "<rootDir>/test/tsconfig.json",
// },
// },
// transform: {
// "^.+\\.ts?$": ["ts-jest", { isolatedModules: true }],
// },
// projects: [
// {
// displayName: "migrate-staking",
// testMatch: "<rootDir>/src/tests/migrate-staking.test.ts",
// },
// ],
// };
//
// export default config;
1 change: 0 additions & 1 deletion public/v3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
return this.toString();
};
</script>
<!-- <script type="module" src="/src/shims.ts"></script> -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
Expand Down
14 changes: 14 additions & 0 deletions remove_scss_comments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Function to remove single-line comments starting with //
remove_single_line_comments() {
sed -i '' 's#//.*$##' "$1"
}

# Find and remove comments in all .scss files
find . -name '*.scss' | while read filename; do
echo "Removing comments from $filename"
remove_single_line_comments "$filename"
done

echo "Comments removed from all .scss files."
13 changes: 5 additions & 8 deletions scripts/vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require('react-scripts/config/env');
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const package = require('../package.json');
const packageJson = require('../package.json');
const { fallback } = require('../config-overrides');
const ignores = [];
const chalk = require('react-dev-utils/chalk');
Expand All @@ -32,7 +32,7 @@ const config = {
target: 'web',
cache: true,
entry: {
vendor: Object.keys(package.dependencies).filter((dep) => !ignores.includes(dep))
vendor: Object.keys(packageJson.dependencies).filter((dep) => !ignores.includes(dep))
},
module: {
rules: [
Expand Down Expand Up @@ -80,12 +80,9 @@ const config = {
path: path.join(vendorPath, `manifest.${vendorHash}.json`)
}),
// fix error 'UnhandledSchemeError: Reading from "node:crypto" is not handled by plugins'
new webpack.NormalModuleReplacementPlugin(
/node:crypto/,
(resource) => {
resource.request = resource.request.replace(/^node:/, '');
}
)
new webpack.NormalModuleReplacementPlugin(/node:crypto/, (resource) => {
resource.request = resource.request.replace(/^node:/, '');
})
]
};

Expand Down
21 changes: 20 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
sonar.projectKey=oraichain_oraiswap-frontend_AYpL50t8tGfUdSAJ_QO4
sonar.projectKey=oraichain_oraiswap-frontend
sonar.organization=oraichain
sonar.exclusions=src/tests/**,src/components/LuckyDraw/luckyDrawClient/LuckyWheelContract.client.ts,src/components/LuckyDraw/luckyDrawClient/LuckyWheelContract.types.ts
sonar.issue.ignore.multicriteria=e1,e2,e3,e4

# Non-interactive elements shouldn't have event handlers.
sonar.issue.ignore.multicriteria.e1.ruleKey=typescript:S6847
sonar.issue.ignore.multicriteria.e1.resourceKey=**

# Remove this commented out code.
sonar.issue.ignore.multicriteria.e2.ruleKey=typescript:S125
sonar.issue.ignore.multicriteria.e2.resourceKey=**

# Prefer using an optional chain expression instead, as it's more concise and easier to read.
sonar.issue.ignore.multicriteria.e3.ruleKey=typescript:S6582
sonar.issue.ignore.multicriteria.e3.resourceKey=**

# Avoid non-native interactive elements.
sonar.issue.ignore.multicriteria.e4.ruleKey=typescript:S6848
sonar.issue.ignore.multicriteria.e4.resourceKey=**
10 changes: 1 addition & 9 deletions src/components/Button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

@include theme() {
background-color: theme-get('neutral-surface-bg-section-3');
// border-color: theme-get('neutral-text-text-token-name');
color: theme-get('neutral-text-text-token-name');
}
}
Expand All @@ -58,14 +57,7 @@

@include theme() {
background-color: theme-get('neutral-surface-bg-section-3');
// border-color: theme-get('neutral-text-text-token-name');
color: theme-get('neutral-text-text-token-name');

svg {
path {
// fill: theme-get('neutral-text-text-token-name');
}
}
}

font-size: 16px;
Expand Down Expand Up @@ -131,4 +123,4 @@
border: 1px;
padding: 4px 16px;
border-radius: 99px;
}
}
3 changes: 0 additions & 3 deletions src/components/Input.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
.input{

}
2 changes: 1 addition & 1 deletion src/components/InputSwap/InputSwap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function InputSwap({ Icon, setIsSelectFrom, token, amount, onChan
type="text"
value={amount}
onValueChange={({ floatValue }) => {
onChangeAmount && onChangeAmount(floatValue);
onChangeAmount?.(floatValue);
}}
/>
</div>
Expand Down
40 changes: 20 additions & 20 deletions src/components/LuckyDraw/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
.btn {
margin-bottom: 10px;
cursor: pointer;
// background: $aqua;


// position: fixed;
// bottom: 10px;
// right: 10px;
// z-index: 100;





// animation: bounce ease-in-out 0.8s infinite;
// -webkit-animation: bounce ease-in-out 0.8s infinite;



// &:hover {
// animation: unset;
// }




img {
width: 100%;
Expand Down Expand Up @@ -50,7 +50,7 @@
width: 100%;
display: flex;
flex-direction: column-reverse;
// justify-content: space-between;

align-items: center;
flex-wrap: wrap;
gap: 12px;
Expand Down Expand Up @@ -80,13 +80,13 @@

.spin {
position: relative;
// border-radius: 50%;
// background: $aqua;



.spinMask {
z-index: 100;
position: absolute;
// background: rgba(7, 10, 19, 0.2);

background: #d7f5bf;
border-radius: 50%;
width: 72px;
Expand Down Expand Up @@ -125,7 +125,7 @@
gap: 4px;

img {
// filter: grayscale(100%);

filter: saturate(3);
}
}
Expand All @@ -152,7 +152,7 @@
text-align: center;

&.done {
animation-iteration-count: 4; // infinite
animation-iteration-count: 4;
animation: wiggle ease-in-out 0.8s;
-webkit-animation: wiggle ease-in-out 0.8s;
}
Expand Down Expand Up @@ -208,8 +208,8 @@
@include theme {
background-color: $primary-text-link;
border-color: theme-get('neutral-white');
// background-color: theme-get('primary-text-text-link');
// border-color: theme-get('neutral-white');


}

transition: 0.2s ease-in-out;
Expand Down Expand Up @@ -239,7 +239,7 @@
height: 100%;
width: 100%;

// background: $aqua;


& > div {
height: 100%;
Expand Down Expand Up @@ -283,7 +283,7 @@
}
}

// Bounce animation


@keyframes bounce {
0%,
Expand Down
19 changes: 0 additions & 19 deletions src/components/ModalCustom/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@

transition: all 0.5s;
transform: translateY(100%);
// visibility: hidden;

&.open {
transform: translateY(0);
// visibility: visible;
}

&.isBottomSheet {
Expand All @@ -62,12 +60,7 @@
border-radius: 12px;
box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.1);

// transition: all 0.5s;
// transform: translateY(100%);

// &.openContent {
// transform: translateY(0);
// }

visibility: hidden;
opacity: 0;
Expand Down Expand Up @@ -144,27 +137,15 @@
.content {
width: 100%;

// display: flex;
// flex-direction: column;
// align-items: center;
// gap: 24px;

padding: 0px 12px;
overflow-y: auto;
height: 100%;
// max-height: calc(100vh - 250px);

@include mobile {
padding: 0px 5px;
}

// @include theme {
// color: theme-get('neutral-text-text-token-name');
// }
// font-size: 16px;
// font-weight: 400;
// line-height: 150%;
// text-align: center;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,5 @@
.chooseWalletModalWrapper {
color: #f7f7f7;
background: #121511;

.downloadPlatform {
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@

/* aiRight/White */

// color: #ffffff;f
@include theme() {
color: theme-get('text-color');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

path {
fill: #777E91;
;
}
}
}
Expand Down
Loading

0 comments on commit 3c6f29e

Please sign in to comment.