sonarlint

Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed. How to refactor and reduce the complexity

痞子三分冷 提交于 2021-02-11 12:46:56
问题 how to reduce the complexity of the given piece of code? I am getting this error in Sonarqube---> Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed. this.deviceDetails = this.data && {...this.data.deviceInfo} || {}; if (this.data && 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 || '

Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed. How to refactor and reduce the complexity

我与影子孤独终老i 提交于 2021-02-11 12:46:41
问题 how to reduce the complexity of the given piece of code? I am getting this error in Sonarqube---> Refactor this method to reduce its Cognitive Complexity from 21 to the 15 allowed. this.deviceDetails = this.data && {...this.data.deviceInfo} || {}; if (this.data && 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 || '

Optimization in constructor parameters

丶灬走出姿态 提交于 2021-01-28 08:41:33
问题 I'm setting parameter directly into DTO which output we are getting from HQL Below is the HQL: @Query(value = "SELECT new com.test.vos.CustomerDetails(firstname, lastName, address1, address2, address3, id, companyName, companyAddress, otherDetails) " + "FROM MstCustomer mc " + "INNER JOIN mc.mstAddress md " + "INNER JOIN mc.MstCompany mComapny " + "WHERE mc.mobileNo = :mobileNo ") public List<CustomerDetails> getCustomerDetails(@Param("mobileNo") Integer mobileNo); DTO : public class

Configure SonarLint Analyzers properties

泪湿孤枕 提交于 2020-12-10 16:05:34
问题 I've added the SonarLint C# Roslyn analyzer to a project (via the SonarAnalyzer for C# NuGet package) in Visual Studio. Is it possible to configure how the analyzer rules operate? For example, the CodeComplexity analyser appears to have a Threshold property to which I'd like to set a different value. I've found a couple of references to a SonarLint.xml file, but creating such a file and locating it at the solution level doesn't seem to have had any effect. Here's the content of the SonarLint

reduce the number of non-empty switch cases sonar lint issue

谁说胖子不能爱 提交于 2020-06-01 06:26:08
问题 I have around 100 non-empty cases inside a switch case. Each case calls different functions. Sonar is showing issue to reduce number of non-empty switch cases to atmost 30. Is there any alternative to implement such switch cases or there is no problem in having any number of switch cases. for(int i=0;i<arrayList.size();i++){ switch(arrayList.get(i)){ case "A": a(); break; case "B": b(10,20); break; ... ... case "ABZ": abz("string1","string2"); break; } } 来源: https://stackoverflow.com

Is there any way to get SonarQube to only warn about incomplete Switch statements?

自作多情 提交于 2020-01-15 08:23:50
问题 Using Java, SonarQube is complaining about switch statements on enum values not having a default: case. The reasoning given is: "The requirement for a final default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. When the switch covers all current values of an enum - and especially when it doesn't - a default case should still be used because there is no guarantee that the enum won't be extended." I

Fields in a “Serializable” class should either be transient or serializable

大城市里の小女人 提交于 2020-01-11 13:18:10
问题 hi i am getting this error in sonar lint : Fields in a "Serializable" class should either be transient or serializable for private final Condition notEmpty = lock.newCondition(); private final Condition notFull = lock.newCondition(); private Comparator comparator; my code is : package com.cgi.atom.common.priorityexec; /** * Created by nageswararao.vesepog on 8/24/2016. */ import java.util.*; import java.util.concurrent.BlockingDeque; import java.util.concurrent.TimeUnit; import java.util

Not able to install sonarlint plugin in Platform: Eclipse Mars.1 (4.5.1)

不想你离开。 提交于 2020-01-09 19:56:06
问题 Trying to install sonar lint plugin in STS tool, it is not installing and says Sonar lint not compatible with this version of eclipse. Find the versions details. Spring Tool Suite Version: 3.7.2.RELEASE Build Id: 201511261048 Platform: Eclipse Mars.1 (4.5.1) 回答1: Hi you can download sonar lint from the follwing URL http://www.sonarlint.org/eclipse/ then follow the steps given below Make sure the download location, Don't unpack the archive file(for windows) Go to install new software option in

Getting remote config file for SonarLint if online, using local if offline

↘锁芯ラ 提交于 2019-12-30 07:23:06
问题 Current My company is currently using checkstyle and findbugs scripts to measure their code quality. I am the one to imigrate those settings into a new SonarQube driven environment. I came to a point when I started wondering, if it was possible, to look the remote config settings of the running SonarQube server up and update the local settings accordingly. Right now, with checkstyle and findbugs it is like this: 1) someone changes the config xml file and uploads it to the server 2) the same