Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

S4144: Functionally one line with line breaks is processed as few lines #840

Open
wiseIron opened this issue Mar 15, 2019 · 1 comment
Open

Comments

@wiseIron
Copy link

Hello.

Our code style implies to move parameters in function call to the next lineif it's too long in one line.

functionName1(externalFunction: () => void): void {
	this.internalFunction(
		'stringOne',
		paramenterOne,
		externalFunction,
		'stringTwo'
	);
}

functionName2(externalFunction: () => void): void {
	this.internalFunction(
		'stringOne',
		paramenterOne,
		externalFunction,
		'stringTwo'
	);
}

Sonar says that they are duplicates. But if I combine function call in one line(which is not acceptable by our style guide) sonar ignore it because in rule "Functions should not have identical implementations" there is an exceptional case "Functions with fewer than 3 lines are ignored."

functionName1(externalFunction: () => void): void {
	this.internalFunction('stringOne', paramenterOne, externalFunction, 'stringTwo');
}

functionName2(externalFunction: () => void): void {
	this.internalFunction('stringOne', paramenterOne, externalFunction, 'stringTwo');
}

Question: Can I somehow configure sonar to process function call with line breaks as one line to exclude this case? (Or this is kind of bug, or maybe feature which I do not understand?☺)

@vilchik-elena
Copy link
Contributor

I don't think it's required to adjust this rule to your case. IMO if this is just couple of times you have this problem, then just "won't fix" the issue. If it's regular, I think there is problem in the code quality, that you need to duplicate such long lines that they don't even fit your limit. Try to refactor.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants