Questions tagged [code-analysis]

Code Analysis is the process of analyzing the code of the application to discover, review, validate or verify certain properties of the application. This is useful during the process of development and for testing the application before it is put in production mode, especially for checking the security related aspects.

Code Analysis is the process of analyzing the code of the application to discover, review, validate or verify certain properties of the application. This is useful during the process of development and for testing the application before it is put in production mode, especially for checking the security related aspects. Code analysis can be classified from several perspectives, including:

1. What can be analyzed: source code or binary code (byte code) of the application can be analyzed. Both of these categories have their pros and cons.

2. How or When should code be analyzed: Code can be analyzed statically (without executing it) or dynamically (while the application is executed). Static analysis, being conservative, is prone to false positive, but it is exhaustive. On the other hand, dynamic analysis, being very accurate, may miss certain behaviors which are not manifested in any of the execution monitored (because dynamic analysis only analyzes code that is executed - i.e. when certain conditions are met)

3. Purpose of the analysis: Flaws can be found, like NULL pointer dereferencing or passing an ASCII string instead of a Unicode string. Furthermore, aspects of the code can be found, like building various graphs of dependencies or deducing the conditions under which recursion will occur.

1882 questions
0
votes
1 answer

Pointer decay warning (C26485) and passing NOTIFYICONDATA member variable to _tcscpy_s

Sample code: void CMeetingScheduleAssistantDlg::CreateBackupTrayNotification(CString strInfoTitle, CString strInfo, CString strTip) { ::ZeroMemory(&m_sNTD, sizeof(NOTIFYICONDATA)); m_sNTD.cbSize = sizeof(NOTIFYICONDATA); m_sNTD.hWnd =…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
3 answers

LPNMITEMACTIVATE and code analysis (C26462)

Why is it that in the source code in the SDK for LPNMITEMACTIVATE it is defined with the asterix to the left? typedef struct tagNMITEMACTIVATE { NMHDR hdr; int iItem; int iSubItem; UINT uNewState; UINT uOldState; …
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
1 answer

Why is VS flagging C26432 for my destructor?

In my header file I have: CPTSDatabase(); virtual ~CPTSDatabase(); void CloseDatabase(); In my source file I have: CPTSDatabase::~CPTSDatabase() { CloseDatabase(); } void CPTSDatabase::CloseDatabase() { if (m_dbDatabase.IsOpen()) …
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
1 answer

C26492 Don't use `const_cast` to cast away const or volatile (type.3)

Here is an interesting discussion about not using const_cast where you are encouraged to use mutable. Here is my code: MENUITEMINFO sInfo{}; sInfo.cbSize = sizeof(MENUITEMINFO); sInfo.fMask = MIIM_STRING; sInfo.dwTypeData =…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
0 answers

Passing a std::unique_ptr as a void* parameter to a function (CPtrArray::Add)

My code: void CAssignSelectedColumnDlg::AddColumnData(CString strHeading, CStringArray* pAryStrNames, int iColumnIndex, int iCustomIndex /*-1*/, BOOL bFixedCustomType /*FALSE*/) { //COLUMN_DATA_S *psData = nullptr; //psData = new…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
1 answer

Warning C26435 Function CXxxx::DoDataExchange should specify exactly one of `virtual`, `override`, or `final` (c.128)

Here is another code analysis warning: Warning C26435 Function CAssignSelectedColumnDlg::DoDataExchange should specify exactly one of virtual, override, or final (c.128). Example (boilerplate MFC code): void…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
0
votes
0 answers

How to disable ALL Code Analysis in VS 2019?

I recently updated from an earlier version of VS 2019 (I don't remember which) to version 16.11.5 and now all my C# code is littered with little gray dots (see screenshot), which I think indicates Code Analysis violations. Is there a way to disable…
0
votes
1 answer

Is there any way of measure the duration of code in a git repo?

I want to know if is possible check how many time in mean a line of code is keeping in the repo. For example In some repositories, somebody appends new features, but they are deleted early, because there was a wrong analysis for example. Any idea if…
Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
0
votes
1 answer

I can't run database analyse in CodeQL

I can't successfully launch a database analyse command. I tried to launch it like this: codeql database analyze test $HOME/codeql-home/codeql-repo/cpp/ql/examples/snippets/function_call.ql --format=csv --output=c_test.csv I got this error: is not…
aelk
  • 1
  • 1
0
votes
1 answer

"Run on live analysis" checkbox is not found in Visual Studio project properties/Code analysis tab

In Visual Studio 2019 v16.11.1, I could not find the "Run on live analysis" checkbox under project properties/Code analysis tab as shown in msdn. I did not find any information in msdn documentation as well. Please help me with what I miss…
0
votes
1 answer

PhpStorm ERROR: Code analysis failed with exception: kotlin.KotlinNullPointerException: null

When I write a function, it gives an error, but when I cut and paste the same function, the error goes away. And when I commit the file, I get the error I specified in the image. Can anyone help with the solution to the problem? Screenshots are…
0
votes
1 answer

Error CA0063 : * Failed to load rule set file Kentor.AuthServices.ruleset' or one of its dependent rule set files

when I build the project (visual studio 2019) in debug mode , I am getting this error but the web application launches fine . Error CA0063 : * Failed to load rule set file Kentor.AuthServices.ruleset' or one of its dependent rule set files.…
cSharp
  • 25
  • 1
  • 8
0
votes
1 answer

In Visual Studio, how can I detect all the occurrences in C++ code of the ternary operator c?e1:e2 where e1 and e2 are not of the same type?

In Visual Studio, how can I detect all the occurrences in C++ code of the ternary operator c?e1:e2 where e1 and e2 are not of the same type? I am not interested in detecting c?1:2 while for example I am interested in c?0:std::string{"Hello world"}.
0
votes
1 answer

how to config webstorm Code Analysis ignore file

[WebStorm] Performing Code Analysis ignore file settings When I use git comit, there also come out from Code Analysis for the 3rd js lib warnings like Comma expresion! How do I config or some how to ignore those 3rd js lib file from git Code…
0
votes
1 answer

PMD for detecting unused code - API usage

I have taken a look at the PMD api which I want to use to detect unused instance variables and methods in a class. I see that it can be invoked from the command line, however I would like to perform a redundancy analysis of my class by invoking PMD…
Joeblackdev
  • 7,217
  • 24
  • 69
  • 106
1 2 3
99
100