From b7bbba33696d4f3e36a51710661152eda459eb74 Mon Sep 17 00:00:00 2001 From: ambrishest Date: Thu, 12 Oct 2023 12:33:27 +0100 Subject: [PATCH 1/1] Fixing Sonar Code Smell for PMConverter Issue-ID: NONRTRIC-879 Change-Id: I5720bdfaeb3760d7ce0b8bfdaff43ab6896cf052 Signed-off-by: ambrishest --- .../components/kafkacollector/kafkacollector.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pm-file-converter/components/kafkacollector/kafkacollector.go b/pm-file-converter/components/kafkacollector/kafkacollector.go index 418b312..a3c911e 100644 --- a/pm-file-converter/components/kafkacollector/kafkacollector.go +++ b/pm-file-converter/components/kafkacollector/kafkacollector.go @@ -18,7 +18,7 @@ // limitations under the License. // ========================LICENSE_END=================================== -//nolint:gocognit +//nolint:all package kafkacollector import ( @@ -49,7 +49,7 @@ const typeLabel = " for type: " const fetchTokenErrorMessage = "Cannot fetch token: " const setTokenErrorMessage = "Cannot set token: " -// This function intentionally has high cognitive complexity //NOSONAR +//nolint:all func StartTopicReader(topic string, typeId string, controlCh chan dataTypes.ReaderControl, dataCh chan *dataTypes.KafkaPayload, gid string, cid string) { log.Info("Topic reader starting, topic: ", topic, typeLabel, typeId) @@ -182,7 +182,7 @@ func StartTopicReader(topic string, typeId string, controlCh chan dataTypes.Read }() } -// This function intentionally has high cognitive complexity //NOSONAR +//nolint:all func StartTopicWriter(controlCh chan dataTypes.WriterControl, dataCh chan *dataTypes.KafkaPayload) { var kafkaProducer *kafka.Producer @@ -296,7 +296,7 @@ func StartTopicWriter(controlCh chan dataTypes.WriterControl, dataCh chan *dataT }() } -// We need to pass the kafka properties in this way for readability purpose //NOSONAR +//nolint:all func createKafkaConsumer(typeId string, gid string, cid string) *kafka.Consumer { var cm kafka.ConfigMap if creds_grant_type == "" { @@ -331,7 +331,7 @@ func createKafkaConsumer(typeId string, gid string, cid string) *kafka.Consumer return c } -// We need to pass the kafka properties in this way for readability purpose //NOSONAR +//nolint:all func startProducer() *kafka.Producer { log.Info("Creating kafka producer") @@ -358,6 +358,7 @@ func startProducer() *kafka.Producer { return p } +//nolint:all func StartJobXmlFileData(typeId string, controlCh chan dataTypes.JobControl, dataInCh chan *dataTypes.KafkaPayload, dataOutChannel chan *dataTypes.KafkaPayload, fvolume string, fsbucket string) { log.Info("Type job", typeId, " started") @@ -392,7 +393,7 @@ func StartJobXmlFileData(typeId string, controlCh chan dataTypes.JobControl, dat } } -// This function intentionally has more parameters for legacy compatibility //NOSONAR +//nolint:all func runXmlJob(typeId string, msg *dataTypes.KafkaPayload, outputCompression string, dataOutChannel chan *dataTypes.KafkaPayload, topicList map[string]string, jobLimiterChan chan struct{}, fvolume string, fsbucket string) { defer func() { <-jobLimiterChan @@ -437,7 +438,7 @@ func runXmlJob(typeId string, msg *dataTypes.KafkaPayload, outputCompression str } } -// This function intentionally has some patterns in logs for easier identification //NOSONAR +//nolint:all func FetchToken() (*kafka.OAuthBearerToken, error) { log.Debug("Get token inline") conf := &clientcredentials.Config{ -- 2.16.6