Repository: provectus/kafka-ui
Issue: Fix sonar code smell warnings 
Labels: scope/backend


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/docker/message.json b/docker/message.json
deleted file mode 100644
index 490cbe1527d..00000000000
--- a/docker/message.json
+++ /dev/null
@@ -1,100 +0,0 @@
-{"message":"hello1","destination":"kafka2"}
-{"message":"hello2","destination":"kafka2"}
-{"message":"hello3","destination":"kafka2"}
-{"message":"hello4","destination":"kafka2"}
-{"message":"hello5","destination":"kafka2"}
-{"message":"hello6","destination":"kafka2"}
-{"message":"hello7","destination":"kafka2"}
-{"message":"hello8","destination":"kafka2"}
-{"message":"hello9","destination":"kafka2"}
-{"message":"hello10","destination":"kafka2"}
-{"message":"hello11","destination":"kafka2"}
-{"message":"hello12","destination":"kafka2"}
-{"message":"hello13","destination":"kafka2"}
-{"message":"hello14","destination":"kafka2"}
-{"message":"hello15","destination":"kafka2"}
-{"message":"hello16","destination":"kafka2"}
-{"message":"hello17","destination":"kafka2"}
-{"message":"hello18","destination":"kafka2"}
-{"message":"hello19","destination":"kafka2"}
-{"message":"hello20","destination":"kafka2"}
-{"message":"hello21","destination":"kafka2"}
-{"message":"hello22","destination":"kafka2"}
-{"message":"hello23","destination":"kafka2"}
-{"message":"hello24","destination":"kafka2"}
-{"message":"hello25","destination":"kafka2"}
-{"message":"hello26","destination":"kafka2"}
-{"message":"hello27","destination":"kafka2"}
-{"message":"hello28","destination":"kafka2"}
-{"message":"hello29","destination":"kafka2"}
-{"message":"hello30","destination":"kafka2"}
-{"message":"hello31","destination":"kafka2"}
-{"message":"hello32","destination":"kafka2"}
-{"message":"hello33","destination":"kafka2"}
-{"message":"hello34","destination":"kafka2"}
-{"message":"hello35","destination":"kafka2"}
-{"message":"hello36","destination":"kafka2"}
-{"message":"hello37","destination":"kafka2"}
-{"message":"hello38","destination":"kafka2"}
-{"message":"hello39","destination":"kafka2"}
-{"message":"hello40","destination":"kafka2"}
-{"message":"hello41","destination":"kafka2"}
-{"message":"hello42","destination":"kafka2"}
-{"message":"hello43","destination":"kafka2"}
-{"message":"hello44","destination":"kafka2"}
-{"message":"hello45","destination":"kafka2"}
-{"message":"hello46","destination":"kafka2"}
-{"message":"hello47","destination":"kafka2"}
-{"message":"hello48","destination":"kafka2"}
-{"message":"hello49","destination":"kafka2"}
-{"message":"hello50","destination":"kafka2"}
-{"message":"hello51","destination":"kafka2"}
-{"message":"hello52","destination":"kafka2"}
-{"message":"hello53","destination":"kafka2"}
-{"message":"hello54","destination":"kafka2"}
-{"message":"hello55","destination":"kafka2"}
-{"message":"hello56","destination":"kafka2"}
-{"message":"hello57","destination":"kafka2"}
-{"message":"hello58","destination":"kafka2"}
-{"message":"hello59","destination":"kafka2"}
-{"message":"hello60","destination":"kafka2"}
-{"message":"hello61","destination":"kafka2"}
-{"message":"hello62","destination":"kafka2"}
-{"message":"hello63","destination":"kafka2"}
-{"message":"hello64","destination":"kafka2"}
-{"message":"hello65","destination":"kafka2"}
-{"message":"hello66","destination":"kafka2"}
-{"message":"hello67","destination":"kafka2"}
-{"message":"hello68","destination":"kafka2"}
-{"message":"hello69","destination":"kafka2"}
-{"message":"hello70","destination":"kafka2"}
-{"message":"hello71","destination":"kafka2"}
-{"message":"hello72","destination":"kafka2"}
-{"message":"hello73","destination":"kafka2"}
-{"message":"hello74","destination":"kafka2"}
-{"message":"hello75","destination":"kafka2"}
-{"message":"hello76","destination":"kafka2"}
-{"message":"hello77","destination":"kafka2"}
-{"message":"hello78","destination":"kafka2"}
-{"message":"hello79","destination":"kafka2"}
-{"message":"hello80","destination":"kafka2"}
-{"message":"hello81","destination":"kafka2"}
-{"message":"hello82","destination":"kafka2"}
-{"message":"hello83","destination":"kafka2"}
-{"message":"hello84","destination":"kafka2"}
-{"message":"hello85","destination":"kafka2"}
-{"message":"hello86","destination":"kafka2"}
-{"message":"hello87","destination":"kafka2"}
-{"message":"hello88","destination":"kafka2"}
-{"message":"hello89","destination":"kafka2"}
-{"message":"hello90","destination":"kafka2"}
-{"message":"hello91","destination":"kafka2"}
-{"message":"hello92","destination":"kafka2"}
-{"message":"hello93","destination":"kafka2"}
-{"message":"hello94","destination":"kafka2"}
-{"message":"hello95","destination":"kafka2"}
-{"message":"hello96","destination":"kafka2"}
-{"message":"hello97","destination":"kafka2"}
-{"message":"hello98","destination":"kafka2"}
-{"message":"hello99","destination":"kafka2"}
-{"message":"hello100","destination":"kafka2"}
\ No newline at end of file
diff --git a/kafka-ui-react-app/package-lock.json b/kafka-ui-react-app/package-lock.json
index c9475fb562b..b47ee3dc5a8 100644
--- a/kafka-ui-react-app/package-lock.json
+++ b/kafka-ui-react-app/package-lock.json
@@ -3047,6 +3047,11 @@
         }
       }
     },
+    "@fortawesome/fontawesome-free": {
+      "version": "5.15.3",
+      "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.3.tgz",
+      "integrity": "sha512-rFnSUN/QOtnOAgqFRooTA3H57JLDm0QEG/jPdk+tLQNL/eWd+Aok8g3qCI+Q1xuDPWpGW/i9JySpJVsq8Q0s9w=="
+    },
     "@hapi/address": {
       "version": "2.1.4",
       "resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
diff --git a/kafka-ui-react-app/package.json b/kafka-ui-react-app/package.json
index bb523c6811b..f33d04cdd8d 100644
--- a/kafka-ui-react-app/package.json
+++ b/kafka-ui-react-app/package.json
@@ -3,6 +3,7 @@
   "version": "0.1.0",
   "private": true,
   "dependencies": {
+    "@fortawesome/fontawesome-free": "^5.15.3",
     "@hookform/error-message": "0.0.5",
     "@rooks/use-outside-click-ref": "^4.10.0",
     "bulma": "^0.9.2",
@@ -33,7 +34,6 @@
   "lint-staged": {
     "*.{js,ts,jsx,tsx}": [
       "eslint -c .eslintrc.json --fix",
-      "git add",
       "npm test -- --bail --findRelatedTests --watchAll=false"
     ]
   },
diff --git a/kafka-ui-react-app/public/index.html b/kafka-ui-react-app/public/index.html
index 5d52ab46268..5faabaa4a7f 100644
--- a/kafka-ui-react-app/public/index.html
+++ b/kafka-ui-react-app/public/index.html
@@ -6,7 +6,6 @@
     <meta name="viewport" content="width=device-width, initial-scale=1" />
     <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
     <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
-    <script defer src="https://use.fontawesome.com/releases/v5.12.0/js/all.js"></script>
     <title>Kafka UI</title>
   </head>
   <body>
diff --git a/kafka-ui-react-app/src/redux/reducers/schemas/reducer.ts b/kafka-ui-react-app/src/redux/reducers/schemas/reducer.ts
index 2f495287b8a..11072289e63 100644
--- a/kafka-ui-react-app/src/redux/reducers/schemas/reducer.ts
+++ b/kafka-ui-react-app/src/redux/reducers/schemas/reducer.ts
@@ -39,8 +39,8 @@ const addToSchemaList = (
   const newState: SchemasState = {
     ...state,
   };
-  newState.allNames.push(payload.subject as string);
-  newState.byName[payload.subject as string] = { ...payload };
+  newState.allNames.push(payload.subject);
+  newState.byName[payload.subject] = { ...payload };
   return newState;
 };
 
diff --git a/kafka-ui-react-app/src/redux/reducers/schemas/selectors.ts b/kafka-ui-react-app/src/redux/reducers/schemas/selectors.ts
index 65df69145cc..5da7fd3f0b5 100644
--- a/kafka-ui-react-app/src/redux/reducers/schemas/selectors.ts
+++ b/kafka-ui-react-app/src/redux/reducers/schemas/selectors.ts
@@ -1,6 +1,7 @@
 import { createSelector } from 'reselect';
 import { RootState, SchemasState } from 'redux/interfaces';
 import { createFetchingSelector } from 'redux/reducers/loader/selectors';
+import { sortBy } from 'lodash';
 
 const schemasState = ({ schemas }: RootState): SchemasState => schemas;
 
@@ -55,6 +56,5 @@ export const getSchema = createSelector(
 
 export const getSortedSchemaVersions = createSelector(
   schemasState,
-  ({ currentSchemaVersions }) =>
-    currentSchemaVersions.sort((a, b) => a.id - b.id)
+  ({ currentSchemaVersions }) => sortBy(currentSchemaVersions, ['id'])
 );
diff --git a/kafka-ui-react-app/src/redux/store/configureStore/dev.ts b/kafka-ui-react-app/src/redux/store/configureStore/dev.ts
index 4a68a5a5137..40e8ea244b0 100644
--- a/kafka-ui-react-app/src/redux/store/configureStore/dev.ts
+++ b/kafka-ui-react-app/src/redux/store/configureStore/dev.ts
@@ -12,13 +12,8 @@ declare global {
 
 export default () => {
   const middlewares = [thunk as ThunkMiddleware<RootState, Action>];
-
   const composeEnhancers =
     window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
-
   const enhancer = composeEnhancers(applyMiddleware(...middlewares));
-
-  const store = createStore(rootReducer, undefined, enhancer);
-
-  return store;
+  return createStore(rootReducer, undefined, enhancer);
 };
diff --git a/kafka-ui-react-app/src/redux/store/configureStore/prod.ts b/kafka-ui-react-app/src/redux/store/configureStore/prod.ts
index 2316c82211d..63d9e28bfaa 100644
--- a/kafka-ui-react-app/src/redux/store/configureStore/prod.ts
+++ b/kafka-ui-react-app/src/redux/store/configureStore/prod.ts
@@ -4,10 +4,6 @@ import rootReducer from 'redux/reducers';
 
 export default () => {
   const middlewares = [thunk];
-
   const enhancer = applyMiddleware(...middlewares);
-
-  const store = createStore(rootReducer, undefined, enhancer);
-
-  return store;
+  return createStore(rootReducer, undefined, enhancer);
 };
diff --git a/kafka-ui-react-app/src/theme/index.scss b/kafka-ui-react-app/src/theme/index.scss
index 0cd8e4978be..bdf0979a948 100644
--- a/kafka-ui-react-app/src/theme/index.scss
+++ b/kafka-ui-react-app/src/theme/index.scss
@@ -1,3 +1,4 @@
+@import '@fortawesome/fontawesome-free/css/all.min.css';
 @import 'bulma';
 @import '~bulma-switch';
 @import 'src/theme/bulma_overrides';


Test patch: