title: Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed. How to refactor and reduce the complexity
body: <p>how to reduce the complexity of the given piece of code? I am getting this error in Sonarqube---&gt; Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed.</p>
  <pre><code>this.deviceDetails = this.data &amp;&amp; {...this.data.deviceInfo} || {};
      if (this.data &amp;&amp; this.data.deviceInfo) {
        this.getSessionInfo();
        // tslint:disable-next-line: no-shadowed-variable
        const { device, driver, ipAddress, port, active, connectionType } = this.data.deviceInfo;
        this.deviceDetails = {
          name: device.name || '',
          manufacturer: device.manufacturer || '',
          deviceType: device.deviceType || '',
          model: device.model || '',
          description: device.description || '',
          managerId: device.deviceManager &amp;&amp; device.deviceManager.managerId || null,
          locationId: device.location &amp;&amp; device.location.locationId || null,
          active: device.active,
          connectionType: connectionType || null,
          driver_id: driver &amp;&amp; driver.driverId || null,
          ipAddress: ipAddress || '',
          port: String(port) || '',
          connectionStatus: active,
        };
        this.oldDeviceDetails = {...this.deviceDetails};
        this.deviceLocation = device.location &amp;&amp; device.location.locationId || null;
      } else {
  </code></pre>