From 219c9d71336b41ef3fe70f9d3d4af170cf79f860 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:20:20 +0000 Subject: [PATCH] refactor: convert logical operator to optional chainining The [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) operator can be used to perform null checks before accessing a property, or calling a function. --- src/app/theme/components/baSidebar/baSidebar.service.js | 2 +- .../theme/components/baSidebar/baSidebarHelpers.directive.js | 2 +- src/app/theme/components/baWizard/baWizardStep.directive.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/theme/components/baSidebar/baSidebar.service.js b/src/app/theme/components/baSidebar/baSidebar.service.js index 3c19627..4e6d75c 100644 --- a/src/app/theme/components/baSidebar/baSidebar.service.js +++ b/src/app/theme/components/baSidebar/baSidebar.service.js @@ -56,7 +56,7 @@ return result; function _iterateSubItems(currentItem) { - currentItem.subMenu && currentItem.subMenu.forEach(function(subItem) { + currentItem.subMenu?.forEach(function(subItem) { subItem.stateRef && result.push(subItem.stateRef); _iterateSubItems(subItem); }); diff --git a/src/app/theme/components/baSidebar/baSidebarHelpers.directive.js b/src/app/theme/components/baSidebar/baSidebarHelpers.directive.js index 94127ea..a5755fe 100644 --- a/src/app/theme/components/baSidebar/baSidebarHelpers.directive.js +++ b/src/app/theme/components/baSidebar/baSidebarHelpers.directive.js @@ -57,7 +57,7 @@ function BaSidebarTogglingItemCtrl($scope, $element, $attrs, $state, baSidebarService) { var vm = this; var menuItem = vm.$$menuItem = $scope.$eval($attrs.baSidebarTogglingItem); - if (menuItem && menuItem.subMenu && menuItem.subMenu.length) { + if (menuItem?.subMenu && menuItem.subMenu.length) { vm.$$expandSubmenu = function() { console.warn('$$expandMenu should be overwritten by baUiSrefTogglingSubmenu') }; vm.$$collapseSubmenu = function() { console.warn('$$collapseSubmenu should be overwritten by baUiSrefTogglingSubmenu') }; diff --git a/src/app/theme/components/baWizard/baWizardStep.directive.js b/src/app/theme/components/baWizard/baWizardStep.directive.js index 126dbd9..7f289b3 100644 --- a/src/app/theme/components/baWizard/baWizardStep.directive.js +++ b/src/app/theme/components/baWizard/baWizardStep.directive.js @@ -38,7 +38,7 @@ } function submit() { - $scope.form && $scope.form.$setSubmitted(true); + $scope.form?.$setSubmitted(true); } function isComplete() {