Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 No good result of Code inspection

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
xMRi Posted - Dec 14 2022 : 08:10:11 AM

static DWORD GetScale(LPCTSTR &lpszText, bool &fError)
{
	fError = false;
	// Wert folgt?
	if (*lpszText!=_T('['))	
		return CResizeWndHandler::SCALE_1_1;

	// Wert laden	
	LONG lValue1 = _tcstol(lpszText+1,const_cast<LPTSTR*>(&lpszText),10);	
	if (*lpszText==_T(']'))
	{
		++lpszText;
		return CResizeWndHandler::SCALE(1,lValue1);
	}
	else if (*lpszText==_T('/'))
	{
		++lpszText;
		LONG lValue2 = _tcstol(lpszText,const_cast<LPTSTR*>(&lpszText),10);
		if (*lpszText==_T(']'))
			++lpszText;
		else
			fError = true;
		return CResizeWndHandler::SCALE(lValue1,lValue2);
	}
	else
	{
		fError = true;
		return CResizeWndHandler::SCALE_1_1;
	}	
}


This line gets an "Unnecessary use of else after early exit.

else if (*lpszText==_T('/'))

The code will be changed to:
static DWORD GetScale(LPCTSTR &lpszText, bool &fError)
{
	// Clear error Flag
	fError = false;
	// Wert folgt?
	if (*lpszText!=_T('['))	
		return CResizeWndHandler::SCALE_1_1;

	// Wert laden	
	LONG lValue1 = _tcstol(lpszText+1,const_cast<LPTSTR*>(&lpszText),10);	
	if (*lpszText==_T(']'))
	{
		// Nur ein Wert
		++lpszText;
		return CResizeWndHandler::SCALE(1,lValue1);
	}
	if (*lpszText==_T('/'))
	{
		// zweiten Wert laden
		++lpszText;
		LONG lValue2 = _tcstol(lpszText,const_cast<LPTSTR*>(&lpszText),10);
		if (*lpszText==_T(']'))
			++lpszText;
		else
			// Syntax Fehler, ans Ende springen
			fError = true;
		return CResizeWndHandler::SCALE(lValue1,lValue2);
	}
	else
	{
		// Syntax Fehler, ans Ende springen
		fError = true;
		return CResizeWndHandler::SCALE_1_1;
	}	
}


For me this code change will alter the code into an unreadable version.
The (original) code with an else is more readable.
I think a switch case here would do a better job.
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Dec 14 2022 : 08:51:13 AM
You get the same suggestion from clang-tidy on the command line, which makes sense, since VA is using clang-tidy for Code Inspection. Personally I tend to agree, it "feels" wrong to remove the else there, but I can see an argument that it is "better". I think this is a case where the rule and our expectations can be going in different directions.

If you find this code inspection more irritating than helpful you can disable this specific check in VA Options.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000