1,895 questions
1
vote
1
answer
175
views
Interface vs concrete type declaration: benchmarking oddity
I am applying code analysis rules to a C# project and am trying to evaluate the merits of CA1859: Use concrete types when possible for improved performance.
Performance is only one consideration here, ...
0
votes
1
answer
37
views
.NET CLI code coverage analysis include module not working as expected
As part of the CI/CD for our project we run code coverage analysis on the pipeline using a similar command to:
dotnet test D:\a\1\s\OurSln.sln
--logger trx --results-directory D:\a\_temp
--...
-1
votes
1
answer
96
views
How do I access declarations (such as variables) inside a function using pygccxml
Given the below code, how would I access the myVar declaration, using pygccxml?
#include <windows.h>
void someFunction()
{
LPBYTE myVar;
}
0
votes
0
answers
13
views
Code analysis tool for Monolith java based application migration to SOA
We have a monolithic application and we want to create multiple service based projects(REST APIs). Is there a product available in market which can measure some of the improvements such as
How much ...
0
votes
1
answer
61
views
Very strange message when analyzing the source code
Very strange message when analyzing the source code.
int? x;
if (x == null) {
//
}
The operand can't be null, so the condition is always 'true'.
Remove the condition.dartunnecessary_null_comparison
...
2
votes
1
answer
233
views
How to disable .NET analyzers from a specific NuGet package
I have a .NET project that references a library from another project via an internal NuGet server. The referenced project uses third party code analyzers (StyleCop) also referenced via NuGet and does ...
1
vote
2
answers
93
views
How to configure Visual Studio not to analyse code in a specific file
Is it possible to tell Visual Studio to not analyze a specific file? In this case, GlobalSuppressions.cs. I can't find any setting for it in options.
I'm also trying to avoid messing up my code with ...
0
votes
1
answer
70
views
I need to count the lines of code in the function's call tree
I have a function in my code. I need to count the lines of code in its call tree. That is, I need to count the number of lines in this function, plus all the lines of code in the functions it calls, ...
0
votes
0
answers
57
views
Is it possible to create custom code analyzers for TypeScript?
I want to know if it is possible to create custom code analyzer for TypeScript like you can for C# and VB# with Roslyn? Are there some frameworks/projects I can leverage to do access AST and semantic ...
2
votes
1
answer
64
views
Is it possible to create custom code analyzers for F#
I would like to know if it is possible to add custom code analyzer for F# like you can for C# / VB# with Roslyn? Are there some frameworks/projects I can leverage to do it?
In addition, I would like ...
1
vote
1
answer
178
views
The caller of the function takes ownership of the data, and is responsible for freeing it
The note quoted in the title can often be found in the documentation of GTk4.
My question is this: Is there a technical way to check a program to determine whether all relevant data has been duly ...
1
vote
0
answers
104
views
Code analysys shows an error, but the code compiles
In the following C code the code analysys (the one from C/C++ vscode extension) highlights an error on DEFINE_INDEXING_FUNCTION macro, but when I compile the code with GCC (gcc -Wall -Wextra filename....
1
vote
1
answer
727
views
How to Convert Json value into Sarif format
how to convert this values into sarif
Vulnerablilites: {
"id": "66c5b89700fbf372c2f1f182",
"method": "post",
"path": "/user",
"type&...
5
votes
0
answers
153
views
Unable to verify if logback is the sole logging implementation with jqassistant
I am trying to verify with jqassistant that we only implement logback (and slf4j) for logging.
I'm using version: 2.4.0 and the analyze goal seems to be successful but it shouldn't be. For testing ...
2
votes
1
answer
99
views
Neo4J database shuts down while using jqassistant 2.4.0 [target store format 'AF4.3.0']
I'm experiencing an unexpected shut down with jqassistant 2.4.0. Neo4J is provoking a fatal exception. Interestingly with jqassistant 2.0.10 I'm not experiencing this problem.
I have an application ...
2
votes
0
answers
95
views
What is the Time Complexity of a function if there is an upper limit to the variable
I have the following piece of code.
void foo(int n){
n=n*n;
for (int i=0;i<n;i++){
if(n<10)
cout << i;
else
break;
}
}
Now I wanted to ask if the time complexity ...
1
vote
0
answers
49
views
Can I use Microsoft's CA3001 code analysis rule in .NET Framework?
Can I use Microsoft's CA3xxx code analysis rules in .NET Framework 4.x? They don't show up in my ruleset:
Is there a way to bring them in? Is this documented anywhere? SO and Google searches are ...
2
votes
1
answer
80
views
White-Listing specific words for Code Analysis rule IDE1006: "These words must begin with upper case characters"
In a C# / .NET project, we have enabled Code Analysis during the build. We use the .editorconfig to customize which rules are enabled/disabled, and the severity (suggestion/warning/error).
One rule ...
1
vote
1
answer
571
views
How I can run code analysis in .NET 6 / 8 application on Debug -> Start
I'm trying to configure my .NET 6 / 8 projects to run code analysis also on Debug => Start Debugging (F5) or Debug => Start Without Debugging (ctrl+F5) , but I can't do that.
Writing something ...
1
vote
0
answers
110
views
Some code analysis IDE* rules stops build only in buld server but not on local machine
I have .editorconfig file for example with this one rule
dotnet_diagnostic.IDE0018.severity = error
I have Directory.Build.props with
<Project>
<PropertyGroup>
<LangVersion>...
0
votes
1
answer
2k
views
Are there any way to export Sonarlint report from Intellij?
I generated the Sonarlint report in Intellij. But there is no any options to export as document. Is it possible to export a report in Intellij?
1
vote
1
answer
282
views
generate incoming call graph
I'm trying to pretty print the method calls until a specific method
for example let's take "DisplayHelp" from this simple random repository
I expect for something like
Shell.ctor -> ...
0
votes
1
answer
166
views
Find line of text in MsgBox with a string literal with VBA regex
I want to know if a line of code in a certain format exists in a workbook's modules, in this case a MsgBox with a string literal, by VBA regex.
pattern1 is found, but pattern2 is not found even when ...
0
votes
0
answers
144
views
Don't resolve typedefs in Visual Studio 2022 tooltips
My program includes OpenCV headers. As a result, Visual Studio resolves a simple std::vector<int> as this:
How can I force Visual Studio to ignore typedefs when detecting the type of a variable?...
0
votes
1
answer
3k
views
Disable "Code analysis" in Visual Studio Code with C++
(Note: this EDITed version is a truncated part of the original OP (kept at the bottom), after this correct comment.
Two separate questions 1 and 2 were also posted. All this improves SO.)
I am slowly ...
1
vote
0
answers
42
views
error CS1056: Unexpected character '$' during code analysis [duplicate]
When I am running the build in C# code analysis from the command line with msbuild on some code I get:
(CoreCompile target) -> SLIP.cs(10,51): error CS1056: Unexpected character '$' [....Libraries....
2
votes
1
answer
241
views
Generate a 'readonly record struct' using Roslyn
I can't generate a readonly record struct using Roslyn.
My code:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
var tree = SyntaxFactory.CompilationUnit()
.AddMembers(
...
0
votes
1
answer
586
views
How can I see debug info about the VS Code Cpptools extension's IntelliSense and Code Analysis?
I've setup VS Code with the ms-vscode.cpptools extension to open my C++ project and I see the IntelliSense and Code Analysis tools running. But I never see anything in my code to suggest they're ...
3
votes
0
answers
347
views
dotnet Code Analysis ignoring certain entries in .editorconfig file
In a test project I am trying to ignore certain Code Analysis warnings, but I am struggling to understand what I am missing. I have a simple dotnet6.0 console app with the following structure.
Project ...
0
votes
2
answers
725
views
How can you distinguish between a standard library call, a third-party library call, and an API call from the repository?
I am working on a project where I have to determine whether a particular call or import is:
From the standard library of the language (Python) I'm using. (I am already considering to use sys....
4
votes
0
answers
575
views
Async method's return decorated with "NotNullIfNotNull" still returns variable that may be null
According to this documentation I can decorate a method with NotNullIfNotNull attribute. However the following code does not work:
using System.Diagnostics.CodeAnalysis;
var a = await Test("abc&...
3
votes
2
answers
168
views
Why is Visual Studio saying this cast from System.Int32 to System.Byte is redundant?
I'm trying to retrieve a type of Byte for a unit test, yet when I do a simple cast as shown below, I get the code analysis info in VS that the cast is redundant. Why? Clearly the cast is needed to ...
0
votes
1
answer
55
views
Generic not-null validator for CA1062 in .NET 6
I have a generic method that ensures an IEnumerable is not null or empty.
public static void IsNotNullOrEmpty<T>(IEnumerable<T> enumerable)
{
if (enumerable == null || !enumerable.Any()...
0
votes
1
answer
906
views
GitLab Code Quality job throws 'dotnet not found'
I'm trying to perform Code Quality test using GitLab CQ tool applying to my .NET 7 project. I'm a quite new it this, so, firstly I added default trigger to my .gitlab-ci.yml for getting this job ...
0
votes
1
answer
73
views
Visual Studio: Prevent CodeAnalysis from running on cs files included via nuget
I'm referencing the BlingFireNuget package in my csproj. It adds a bunch of files to my project, including a couple cs files, like BlingFireUtils.cs. These are adding hundreds of code analysis ...
0
votes
2
answers
381
views
MIPS - and instruction of zero - Register
I've got the instruction to understand a MIPS - code. One line of it is the following one:
and $t6, $zero, $zero
Which purpose does it have ? There is the and - instruction of two zero - constants. So ...
-2
votes
1
answer
4k
views
Sonarqube Refactor the below code to reduce its cognitive complexity. Complexity is 33, we should reduce to 15 [duplicate]
As the below code is having nested if conditions, sonarcube complexity is increasing.
Need to reduce the cognitive complexity from 33 to 15 allowed.
I have tried placing only one try block and one ...
2
votes
0
answers
144
views
Visual Studio 2019, Code Analysis [Warning C6386: Buffer overrun], C
Warning C6386, as described by Microsoft, "...indicates that the writable extent of the specified buffer might be smaller than the index used to write to it. This defect can cause buffer overrun&...
0
votes
1
answer
698
views
ReSharper stopped tracking Visual Studio code analysis after VS was updated to 17.5
I have some C# solutions which use StyleCop analyser and Ruleset file with some custom rules. Then I have updated Visual Studio from 17.4 to 17.5.1 and ReSharper stopped tracking violations of rules.
...
0
votes
1
answer
403
views
How to determine Java Version per Android OS version
I was looking (hoping) for a simple mapping from each android OS version to a version of Java.
More specifically. I am focusing on the Android OS side (not the application side), the ART: what version ...
0
votes
1
answer
137
views
Warning when nullable int is involved in an arithmetic operation
The following code doesn't produce any warning or error:
int? test1 = null;
var test2 = test1 + 123;
test1++;
var test3 = test1;
test2 and test3 end up being null. I find this rather unintuitive and ...
1
vote
1
answer
4k
views
difference between overall code and new code in sonarqube
I am new to sonarqube and I don't understand how it works.
I have downloaded the latest sonarqube image, I run a simple container and the application starts, everything ok. Community Edition Version 9....
0
votes
0
answers
54
views
Can you efficiently analyse the type of method parameters in Python
I am making a PyCharm plugin that will generate code examples based on a Python class. The user will be able to select a class and the plugin will generate code examples that utilise the attributes ...
3
votes
0
answers
271
views
How to resolve Security code scan SCS0016 in API controller
We have implemented weather API controller to update weather data and inherited ControllerBase in API controller with APIController action filter like below and enabled security code scan.
using ...
0
votes
0
answers
57
views
MsBuild: Fail the Build when referenced Projects outside of the solution have Code Analaysis warnings
In one of our .net Projects we have a Build/Publish discrepancy. The Build succeeds but the publish fails.
The reason for that:
We have a lot of shared Projects which are just dependencies but are not ...
0
votes
1
answer
136
views
How can I select the entire import statements using regular expressions?
I'm writing a static code analysis tool in Python.
Here's a sample of a code that needs to be analyzed:
import {
component$,
useClientEffect$,
} from '@builder.io/qwik'
import Swiper from '...
1
vote
1
answer
377
views
Dynamically compile code from .Net Standard 2.0
I'm developing a .Net Standard 2.0 library offering dynamic compilation but there are always missing references.
A consumer using .Net Core, calls an Api with his source code as text, implementing a ...
1
vote
1
answer
766
views
Some of ReSharper settings not visible
I have downloaded ReSharper to Visual Studio 2022. I need to run code analysis to check if all varables are named correctly in camelCase.
Also I want to implement custom rule that no double or float ...
3
votes
1
answer
338
views
CAExcludePath is being ignored during Visual Studio code analysis
I have a Visual Studio C++ application project MyApp and a Visual Studio C++ library project Lib. The MyApp project has Lib project added as a project reference, as well as $(ProjectDir)..\Lib; added ...
3
votes
1
answer
2k
views
SuppressMessage compiler warning CS1591 for generated code (xsd.exe)
I'm using the tool xsd.exe in several projects to generate classes for my data model.
When turning on documentation file generation in my csproj the compiler starts to show lots of warnings of type: ...