Skip to content

Commit

Permalink
fixes sonar issues (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrim committed Feb 27, 2024
1 parent ff27f02 commit c068a4c
Show file tree
Hide file tree
Showing 44 changed files with 186 additions and 3,940 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"jsx-a11y/no-noninteractive-element-interactions": "off",
"jsx-a11y/anchor-is-valid": "off",
"no-console": "off",
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
"no-unused-expressions": "off",
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off",
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ jobs:
-Dsonar.organization=tyktechnologies
-Dsonar.projectKey=TykTechnologies_tyk-ui
-Dsonar.sources=./src
-Dsonar.exclusions=src/common/sass/fontawesome.scss,src/common/sass/tykon.scss
-Dsonar.coverage.exclusions=cypress/**/*.js,**/*.test.js,src/form/components/Combobox/*.js,src/form/components/Input/*.js,src/form/redux-form/**/*.js
-Dsonar.cpd.exclusions=**/*.test.js,src/form/redux-form/**/*,src/common/fonts/**/*,src/form/components/Combobox/*.js,src/form/components/Input/*.js
-Dsonar.test.inclusions=**/*.test.js
-Dsonar.tests=./src
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.eslint.eslintconfigpath=.eslintrc
-Dsonar.issue.ignore.multicriteria=S6847,S6819,S3358
-Dsonar.issue.ignore.multicriteria.S6847.ruleKey=javascript:S6847
-Dsonar.issue.ignore.multicriteria.S6847.resourceKey=**/*
-Dsonar.issue.ignore.multicriteria.S6819.ruleKey=javascript:S6819
-Dsonar.issue.ignore.multicriteria.S6819.resourceKey=**/*
-Dsonar.issue.ignore.multicriteria.S3358.ruleKey=javascript:S3358
-Dsonar.issue.ignore.multicriteria.S3358.resourceKey=**/*
env:
CI: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ jobs:
-Dsonar.organization=tyktechnologies
-Dsonar.projectKey=TykTechnologies_tyk-ui
-Dsonar.sources=./src
-Dsonar.exclusions=src/common/sass/fontawesome.scss,src/common/sass/tykon.scss
-Dsonar.coverage.exclusions=cypress/**/*.js,**/*.test.js,src/form/components/Combobox/*.js,src/form/components/Input/*.js,src/form/redux-form/**/*.js
-Dsonar.cpd.exclusions=**/*.test.js,src/form/redux-form/**/*,src/common/fonts/**/*,src/form/components/Combobox/*.js,src/form/components/Input/*.js
-Dsonar.test.inclusions=**/*.test.js
-Dsonar.tests=./src
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.eslint.eslintconfigpath=.eslintrc
-Dsonar.issue.ignore.multicriteria=S6847,S6819,S3358
-Dsonar.issue.ignore.multicriteria.S6847.ruleKey=javascript:S6847
-Dsonar.issue.ignore.multicriteria.S6847.resourceKey=**/*
-Dsonar.issue.ignore.multicriteria.S6819.ruleKey=javascript:S6819
-Dsonar.issue.ignore.multicriteria.S6819.resourceKey=**/*
-Dsonar.issue.ignore.multicriteria.S3358.ruleKey=javascript:S3358
-Dsonar.issue.ignore.multicriteria.S3358.resourceKey=**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ coverage
*DS_Store
cypress/screenshots
.vscode
.scannerwork
622 changes: 0 additions & 622 deletions src/common/fonts/smoolthan_medium-demo.html

This file was deleted.

622 changes: 0 additions & 622 deletions src/common/fonts/smoolthan_medium-italic-demo.html

This file was deleted.

622 changes: 0 additions & 622 deletions src/common/fonts/smoolthan_regular-demo.html

This file was deleted.

622 changes: 0 additions & 622 deletions src/common/fonts/smoolthan_regular-italic-demo.html

This file was deleted.

622 changes: 0 additions & 622 deletions src/common/fonts/smoolthan_thin-demo.html

This file was deleted.

622 changes: 0 additions & 622 deletions src/common/fonts/smoolthan_thin-italic-demo.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/common/sass/reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}

Expand Down
64 changes: 25 additions & 39 deletions src/common/sass/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ label {
font-size: text-scale('sm');
line-height: line-height('sm');
font-family: $font-family-regular;

a {
font-size: text-scale('sm');
text-decoration: underline;
}
}

strong {
Expand All @@ -52,7 +57,7 @@ a:not(.tyk-button) {
cursor: pointer;
color: $text-color;
font-family: $font-family-regular;

&.link--bold {
font-family: $font-family-bold;
}
Expand All @@ -66,14 +71,6 @@ a:not(.tyk-button) {
}
}

p,
label {
a {
font-size: text-scale('sm');
text-decoration: underline;
}
}

.font-family-regular {
font-family: $font-family-regular;
}
Expand All @@ -94,18 +91,9 @@ label {
}

.text {
&--primary {
color: theme-color('primary', 'base');
}
&--danger {
color: theme-color('danger', 'base');
}
&--info {
color: theme-color('info', 'base');
}
&-warning {
color: theme-color('warning', 'base');
}
&--medium {
font-family: $font-family-medium;
}
Expand All @@ -123,6 +111,25 @@ label {
&--underline {
text-decoration: underline;
}

&--default-light {
color: theme-color('default', 'light') !important;
}
&--default {
color: theme-color('default', 'base') !important;
}
&--primary {
color: theme-color('primary', 'base') !important;
}
&--danger {
color: theme-color('danger', 'base') !important;
}
&--success {
color: theme-color('success', 'base') !important;
}
&--warning {
color: theme-color('warning', 'base') !important;
}
}

td.text-ellipsis {
Expand Down Expand Up @@ -160,24 +167,3 @@ td.text-ellipsis {
margin-left: 5px;
}
}

.text {
&--default-light {
color: theme-color('default', 'light') !important;
}
&--default {
color: theme-color('default', 'base') !important;
}
&--primary {
color: theme-color('primary', 'base') !important;
}
&--danger {
color: theme-color('danger', 'base') !important;
}
&--success {
color: theme-color('success', 'base') !important;
}
&--warning {
color: theme-color('warning', 'base') !important;
}
}
22 changes: 13 additions & 9 deletions src/components/Chart/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {
useState, useEffect, useRef, memo,
useState, useEffect, useMemo, useRef, memo,
} from 'react';
import PropTypes from 'prop-types';
import * as echarts from 'echarts';
Expand All @@ -26,7 +26,7 @@ function Chart({
zoomEnd,
title,
seriesConfig = [],
noDataComponent = null,
noDataComponent: noDataComponentProp = null,
zoomColors,
style,
}) {
Expand All @@ -38,6 +38,17 @@ function Chart({
}
};

const noDataComponent = useMemo(
() => (noDataComponentProp
? noDataComponentProp()
: (
<Message theme="info">
No data to display
</Message>
)),
[noDataComponentProp],
);

const lineBarChart = {
defaultOpts: fromJS({
title: {
Expand Down Expand Up @@ -412,16 +423,9 @@ function Chart({
ref={chartWrapperRef}
/>
{
/* eslint-disable-next-line no-nested-ternary */
chartHasData()
? null
: noDataComponent
? noDataComponent()
: (
<Message theme="info">
No data to display
</Message>
)
}
</div>
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/List/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { fromJS } from 'immutable';
import ListItem from './js/ListItem';

function List(props) {
Expand Down Expand Up @@ -28,7 +27,7 @@ function List(props) {
};

const getListStyle = () => {
const styleCopy = fromJS(style).toJS();
const styleCopy = structuredClone(style);
if (labelwidth) {
styleCopy.flexBasis = `calc(100% - ${labelwidth} - 20px)`;
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ Modal.Header = ({ children }) => {
</div>
);
};
Modal.Header.propTypes = {
children: PropTypes.element,
};
/* eslint-disable-next-line */
Modal.Title = ({ children }) => {
console.warn('%cModal.Title%c is deprecated.', 'font-weight: bold', '');
Expand All @@ -105,6 +108,9 @@ Modal.Title = ({ children }) => {
</h4>
);
};
Modal.Title.propTypes = {
children: PropTypes.element,
};

Modal.propTypes = {
children: PropTypes.oneOfType([
Expand Down
26 changes: 10 additions & 16 deletions src/components/Panel/sass/Panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
border: $general-border-width solid theme-color('danger', 'base');
}

&__header {
align-items: center;
border-bottom: 1px solid $panel-default-border-bottom-color;
display: flex;
font-family: $font-family-regular;

> .tyk-icon,
> .tyk-tooltip__wrapper {
margin-left: 5px;
}
}

.tyk-panel {
border: $general-border-width solid theme-color('default', 'light');
box-shadow: none;
Expand Down Expand Up @@ -57,13 +45,11 @@

.tyk-panel__header {
@include panel-variant($panel-primary-header-color, $panel-primary-header-text-color);
border: $panel-primary-border-color;
}

.tyk-panel__body {
@include panel-variant($panel-primary-body-color, $panel-primary-body-text-color);
}
.tyk-panel__header {
border: $panel-primary-border-color;
@include panel-variant($panel-primary-body-color, $panel-primary-body-text-color);
}

& .tyk-form-group {
Expand Down Expand Up @@ -121,6 +107,9 @@
}

.tyk-panel__header {
display: flex;
align-items: center;
border-bottom: 1px solid $panel-default-border-bottom-color;
border-radius: $panel-border-radius;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
Expand All @@ -129,6 +118,11 @@
padding: $padding-y-panel-header $padding-x-panel-header;
position: relative;

> .tyk-icon,
> .tyk-tooltip__wrapper {
margin-left: 5px;
}

.tyk-panel--collapsed & {
border-bottom-left-radius: $panel-border-radius;
border-bottom-right-radius: $panel-border-radius;
Expand Down
9 changes: 3 additions & 6 deletions src/components/Table/sass/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
line-height: line-height('sm');
font-family: $font-family-bold;
text-transform: uppercase;
padding: $table-th-padding;

&:last-child {
border-right: none;
Expand All @@ -49,10 +50,6 @@
}
}

> thead th {
padding: $table-th-padding;
}

> tbody tr:hover {
background: rgba(theme-color('background', 'light'), 0.4);
}
Expand All @@ -67,7 +64,7 @@
&:last-child {
border-right: none;
}

vertical-align: middle;

&.fit {
Expand Down Expand Up @@ -97,7 +94,7 @@
border-top: 1px solid theme-color('default', 'light');
transition: all .4s linear;
border-radius: $general-border-radius;

&.clickable {
cursor: pointer;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function Tabs(props) {

const key = tempPath.shift();

return !!(tempTabs && tempTabs[key]);
return Boolean(tempTabs?.[key]);
};

const context = useMemo(() => ({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/js/TabContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function TabContent(props) {
useEffect(() => {
if (
tabExists(path) && tabData?.title
&& (prevTabData?.title !== tabData?.title || prevTabData.selected !== tabData.selected)
&& (prevTabData?.title !== tabData?.title || prevTabData?.selected !== tabData.selected)
) {
const tempTabData = { ...tabData };
updateTab(tempTabData, path);
Expand Down
1 change: 0 additions & 1 deletion src/components/Toast/Toast.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import toast from './index';

/* eslint-disable react/destructuring-assignment */
function Component(props) {
// eslint-disable-next-line react/jsx-no-useless-fragment
return props.children || <button type="button" onClick={props.onClick}>Show Toast</button>;
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/Toast/js/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ function ToastContainer(props) {
const tempMessages = { ...messages };
delete tempMessages[index];
setMessages((prevMessages) => {
const { [index]: messageToBeRemoved, ...restMessages } = prevMessages;
return restMessages;
const newMessages = { ...prevMessages };
delete newMessages[index];
return newMessages;
});
};

Expand Down
Loading

0 comments on commit c068a4c

Please sign in to comment.