Repository: manusa/electronim
Pull request #185 (2022-11-05 05:50:29)

♻️ instance initializer method names renamed

sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=manusa_electronim&pullRequest=185)

[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=BUG)  
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=VULNERABILITY)  
[![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=manusa_electronim&pullRequest=185&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=manusa_electronim&pullRequest=185&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=manusa_electronim&pullRequest=185&resolved=false&types=SECURITY_HOTSPOT)  
[![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=manusa_electronim&pullRequest=185&resolved=false&types=CODE_SMELL)

[![100.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/100-16px.png '100.0%')](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=185&metric=new_coverage&view=list) [100.0% Coverage](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=185&metric=new_coverage&view=list)  
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=185&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=manusa_electronim&pullRequest=185&metric=new_duplicated_lines_density&view=list)



Patch:
diff --git a/src/app-menu/index.js b/src/app-menu/index.js
index 4341e8c..be8e4dd 100644
--- a/src/app-menu/index.js
+++ b/src/app-menu/index.js
@@ -24,7 +24,11 @@ const webPreferences = {
   preload: path.resolve(__dirname, '..', '..', 'bundles', 'app-menu.preload.js')
 };
 
-const initAppMenu = () => {
+/**
+ * Creates a new BrowserView instance with the App Menu
+ * @returns {Electron.CrossProcessExports.BrowserView}
+ */
+const newAppMenu = () => {
   const appMenu = new BrowserView({webPreferences});
   appMenu.isAppMenu = true;
   appMenu.setAutoResize({width: false, horizontal: false, height: false, vertical: false});
@@ -34,4 +38,4 @@ const initAppMenu = () => {
 
 const isNotAppMenu = bv => bv.isAppMenu !== true;
 
-module.exports = {initAppMenu, isNotAppMenu};
+module.exports = {newAppMenu, isNotAppMenu};
diff --git a/src/chrome-tabs/index.js b/src/chrome-tabs/index.js
index d22ad71..b06c2c5 100644
--- a/src/chrome-tabs/index.js
+++ b/src/chrome-tabs/index.js
@@ -42,7 +42,11 @@ const handleContextMenu = (event, params) => {
   menu.popup({x, y});
 };
 
-const initTabContainer = () => {
+/**
+ * Creates a new BrowserView instance with the Chrome Tabs
+ * @returns {Electron.CrossProcessExports.BrowserView}
+ */
+const newTabContainer = () => {
   const tabContainer = new BrowserView({webPreferences});
   tabContainer.isTabContainer = true;
   tabContainer.setAutoResize({width: false, horizontal: false, height: false, vertical: false});
@@ -55,5 +59,5 @@ const initTabContainer = () => {
 const isNotTabContainer = bv => bv.isTabContainer !== true;
 
 module.exports = {
-  TABS_CONTAINER_HEIGHT, initTabContainer, isNotTabContainer
+  TABS_CONTAINER_HEIGHT, newTabContainer, isNotTabContainer
 };
diff --git a/src/main/index.js b/src/main/index.js
index 51f2ba4..a8ab195 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -15,8 +15,8 @@
  */
 const {BrowserWindow, Notification, app, desktopCapturer, ipcMain: ipc, nativeTheme} = require('electron');
 const {APP_EVENTS} = require('../constants');
-const {initAppMenu, isNotAppMenu} = require('../app-menu');
-const {TABS_CONTAINER_HEIGHT, initTabContainer, isNotTabContainer} = require('../chrome-tabs');
+const {newAppMenu, isNotAppMenu} = require('../app-menu');
+const {TABS_CONTAINER_HEIGHT, newTabContainer, isNotTabContainer} = require('../chrome-tabs');
 const {openHelpDialog} = require('../help');
 const {loadSettings, updateSettings, openSettingsDialog} = require('../settings');
 const {
@@ -182,7 +182,7 @@ const saveSettings = (_event, settings) => {
   tabManager.removeAll();
   const viewsToDestroy = [currentBrowserView, tabContainer];
   viewsToDestroy.forEach(view => view.webContents.destroy());
-  tabContainer = initTabContainer();
+  tabContainer = newTabContainer();
 };
 
 const initGlobalListeners = () => {
@@ -200,8 +200,8 @@ const initGlobalListeners = () => {
 
 const browserVersionsReady = () => {
   app.userAgentFallback = userAgentForView(mainWindow);
-  tabContainer = initTabContainer();
-  appMenu = initAppMenu();
+  tabContainer = newTabContainer();
+  appMenu = newAppMenu();
 };
 
 const init = () => {


Test patch:
diff --git a/src/chrome-tabs/__tests__/index.test.js b/src/chrome-tabs/__tests__/index.test.js
index 6d0813c..8b3cd68 100644
--- a/src/chrome-tabs/__tests__/index.test.js
+++ b/src/chrome-tabs/__tests__/index.test.js
@@ -28,10 +28,10 @@ describe('Chrome Tabs Module module test suite', () => {
     };
     chromeTabs = require('../');
   });
-  describe('initTabContainer', () => {
+  describe('newTabContainer', () => {
     test('webPreferences is sandboxed and has no node integration', () => {
       // When
-      chromeTabs.initTabContainer(mainWindow);
+      chromeTabs.newTabContainer(mainWindow);
       // Then
       const BrowserView = require('electron').BrowserView;
       expect(BrowserView).toHaveBeenCalledTimes(1);
diff --git a/src/main/__tests__/index.test.js b/src/main/__tests__/index.test.js
index 7c594d3..f35d9a6 100644
--- a/src/main/__tests__/index.test.js
+++ b/src/main/__tests__/index.test.js
@@ -56,7 +56,7 @@ describe('Main module test suite', () => {
       nativeTheme: mockNativeTheme
     }));
     appMenuModule = require('../../app-menu');
-    jest.spyOn(appMenuModule, 'initAppMenu');
+    jest.spyOn(appMenuModule, 'newAppMenu');
     settingsModule = require('../../settings');
     jest.spyOn(settingsModule, 'loadSettings').mockImplementation(() => mockSettings);
     jest.spyOn(settingsModule, 'updateSettings').mockImplementation();
@@ -179,7 +179,7 @@ describe('Main module test suite', () => {
           mockAppMenu = {
             setBounds: jest.fn()
           };
-          jest.spyOn(appMenuModule, 'initAppMenu').mockImplementation(() => mockAppMenu);
+          jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
           main.init();
         });
         test('should set app-menu bounds', () => {
@@ -498,7 +498,7 @@ describe('Main module test suite', () => {
     test('appMenuOpen, should show and resize app-menu', () => {
       // Given
       const mockAppMenu = {setBounds: jest.fn()};
-      jest.spyOn(appMenuModule, 'initAppMenu').mockImplementation(() => mockAppMenu);
+      jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
       main.init();
       // When
       mockIpc.listeners.appMenuOpen();
@@ -510,7 +510,7 @@ describe('Main module test suite', () => {
     test('appMenuClose, should hide app-menu', () => {
       // Given
       const mockAppMenu = {isTheMockAppMenu: true};
-      jest.spyOn(appMenuModule, 'initAppMenu').mockImplementation(() => mockAppMenu);
+      jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
       main.init();
       // When
       mockIpc.listeners.appMenuClose();