warden
(Radek Antoniuk)
July 8, 2021, 10:12am
1
TypeScript + AWS CDK.
Code example:
new CfnOutput(this, 'test', {});
This is for the TypeScript rule: Objects should not be created to be dropped immediately without being used:
It is perfectly fine to just define it and not assign it or use it as this define Infrastructure as Code component.
#!/usr/bin/env node
import * as route53 from 'aws-cdk-lib/aws-route53';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
import * as targets from 'aws-cdk-lib/aws-route53-targets';
import * as cloudfront_origins from 'aws-cdk-lib/aws-cloudfront-origins';
import { CfnOutput, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Construct } from 'constructs';
export interface StaticSiteProps {
domainName: string;
siteSubDomain: string;
}
/**
* Static site infrastructure, which deploys site content to an S3 bucket.
*
This file has been truncated. show original
1 Like
Yassin
(Yassin Kammoun)
July 14, 2021, 12:48pm
2
Hello Radek,
Thank you for your message.
Given the example you shared, I do understand that’s how the API of AWS CDK is supposed to be used. Still, we consider that creating a new object just for the sake of side effects and not using the resulting instance afterwards is a bad practice (or a bad design) as it is rightfully explained by the rule description.
Coming back to your problem, I think it would makes sense for you to disable the rule to avoid these false-positives.
Hope this helps,
Yassin
warden
(Radek Antoniuk)
August 3, 2021, 8:32am
3
Hi Yassin,
Indeed, I have disabled the rule with an undocumented method - see my comment here:
Hello, I’m wondering how I might set the setting sonar.issue.ignore.block in the sonar-project.properties file?
I see from the SonarCloud UI the web form has the name for the block begin and end regex patterns as settings[sonar.issue.ignore.block][beginBlockRegexp] and settings[sonar.issue.ignore.block][endBlockRegexp], but this does not help me understand how to set this value in a .properties file.
Thanks
It would be great to add this to the official docs.
system
(system)
Closed
August 10, 2021, 8:33am
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.