General
26 results found
-
Add Support for Modified Cyclomatic Complexity
It would be nice if support was added for "Modified" cyclomatic complexity. It's the metric we prefer to use because we agree that the number of cases a switch statement contains doesn't make a significant difference in how difficult it is to understand the switch statement.
From https://www.unix.com/man-page/debian/1/pmccabe/
…Modified McCabe Cyclomatic Complexity | Traditional McCabe Cyclomatic Complexity | | # Statements in function | | | First line of function | | | | # lines in function | | | | | filename(definition line number):function | | | | | | 5 6 11 34 27 gettoken.c(35): matchparen Column
5 votesHi Kevin,
The metric you are looking for is defined as:
+metric(function.cyclomatic_complexity_switch_modified = function.cyclomatic_complexity - function.num_switch_cases + function.num_switch_stmts)
Keep in mind that this will not work on the current version PC-lint Plus 2.0 and will work on the upcoming beta. Since the function needed to make this metric num_switch_cases is not available in PC-lint Pus 2.0. The emails for the beta release will be sent out soon.
-
Expedite support for C++20
I used PC-Lint many years ago, and was quite satisfied. Just to see what the current state of the program was, I pasted a bit of code I was working on into your online evaluator. Unfortunately, it couldn't handle a number of bits of C++20-specific code. (It also refused to recognize the VS flag /std:c++latest, which is legitimate.)
13 votesThe recently released PC-lint Plus 2.0 supports most of C++20 allowing it to be used with current versions of most compilers, including Visual Studio 2022. The -std=c++20 option may be used to enable support for C++20. The Online Demo will be updated with the new version soon, in the mean time an evaluation version of 2.0 is available for download here.
-
HIS Source Code Metrics
The Hersteller Initiative Software (HIS) source code metrics define recommended thresholds for a set of key code quality metrics, to help ensure efficient project and quality management. The HIS Metriken set was originally defined by several large automotive manufacturers (including Audi, BMW Group, DaimlerChrysler, Porsche and Volkswagen), to provide an agreed standard for developing higher quality and more maintainable code for automotive systems.
The HIS metric set is still widely used within the automotive industry today and many of the same metrics are now specifically required by the ISO 26262 automotive functional safety (FuSa) standard (Section 6). However, the guidelines…
8 votesThe recently released PC-lint Plus version 2.0 includes a comprehensive Metrics solution that provides the ability to report the values of dozens of built in metrics, define custom metrics, and diagnose situations where metrics exceed specified thresholds. This feature supports calculation and reporting of HIS metrics. See Chapter 10 of the version 2.0 Reference Manual for details.
-
Add support for MISRA C 2012 addendum 1
automotive industry requirement to comply with additional 16 rules documented in the addendum
1 vote -
Add support for AUTOSAR coding guidelines
Now that PC-LINT plus is based on clang it should be fairly easy to come up with an author file for https://www.autosar.org/fileadmin/user_upload/standards/adaptive/17-03/AUTOSAR_RS_CPP14Guidelines.pdf which basically adds C++14 on top of MISRA C++ 2008 (which itself is working on a revised standard).
15 votesIntroductory support for AUTOSAR is included in PC-lint Plus version 1.3.
-
compute function cyclomatic complexity...
...and issue message if above a threshold.
Since you're already analyzing the functions, it would seem to be a relatively minor addition to compute a cyclomatic complexity for the function (he said, while signing up someone else to do all the work).
Then, similarly to the "-size" option, the user could be allowed to set a max complexity, above which an info message could be generated.
This would help reduce our reliance on additional tools.
35 votesThe recently released PC-lint Plus version 2.0 provides a comprehensive Metrics solution that provides the ability to report the values of dozens of built in metrics, including cyclomatic complexity, define custom metrics, and diagnose situations where metrics exceed specified thresholds. See Chapter 10 of the version 2.0 Reference Manual for details.
-
generate an Info message for inefficient structure packing
Since PC-Lint already has the size and alignment information, it could determine if structures members are not arranged most efficiently.
For example, in a standard 32-bit system, a structure defined as
struct foo
{
uint32t a;
uint8t b;
uint16_t c;
}is not most efficiently arranged, requiring an additional padding byte between b and c to achieve the necessary alignment for c. A more efficient method would be to define foo as
struct foo
{
uint32t a;
uint16t b;
uint8_t c;
}I think Lint could determine this and generate some Info message for struct name.
9 votesHi Michael,
Thank you for the suggestion. In this case, you can implement a query to report on this issue e.g.
-astquery(
persistent $size = 100
persistent $name = RecordDecl.getNameAsString
if FieldDecl {
FieldDecl : {
if getParent.isStruct{
echo{ $size = getType.getTypeSizeInBits}
echo{ $name = getParent.getNameAsString}
}
if getType.getTypeSizeInBits > $size {
getParent.getNameAsString == $name
message(8001 "Inefficient structure packing. '" currentnode "' is larger than the previous declaration.")
}
}
})
This query will report on the example provided e.g.
//lint -w1 +e8001
#include <stdint.h>
struct foo
{
uint32_t g;
uint16_t h;
uint8_t i;
};
struct foo1
{
uint32_t a;
uint8_t c;
uint16_t b; //Reports here.
};
Output:
Message 8001: (info -- Inefficient structure packing. 'foo1::b' is larger than the previous declaration.)
This query can be placed in a .lnt file and passed to PC-lint Plus as an argument. The documentation for queries can be found in section 16 of…
-
Error 305: Unable to open module 'Files'
Minor irritation, unclear error message: Using separate directories for exe and lint files creates the following problem unless the path variable is also set to the exe location. Not clear exactly which files lint requires, so have to copy all over (don't want path modified).
c:\"Program Files (x86)\pc-lint 9.0"\lint-nt -v
PC-lint for C/C++ (NT) Vers. 9.00L, Copyright Gimpel Software 1985-2014
Error 305: Unable to open module 'Files'1 voteIt is not clear what the issue here is, please email support for assistance.
-
Add output of the received and expected types for messages that indicate type differences
With the MISRA 2012 "essential type" implementation, we often see messages that indicated "Expression assigned to a narrower or different essential type" or "Composite expression with smaller essential type than other operand". For these types of messages that indicate a discrepancy of type, it would help in debugging these messages if the types involved could be added into the output.
3 votes -
Expected Warning 438: Last value assigned to variable not used
Hi,
For the following code I really expected lint
warning 438. However, lint isn't complaining about
that. Not even when I use -w4 (it complains about
using ++ inside a function call, but not about
438, which is more serious in my opinion)extern int f(void);
extern void g(int x);void bla(void)
{
int x = f();
g(x++);
}Am I misunderstanding something, or is Lint really
lacking here?Note: If I change the code to do
g(x)
x++;Which I would think is 'the same', I do get the
438 lint warning of course.Best regards,
Arnaud Gouder de…
18 votesThis issue has been corrected in the upcoming PC-lint Plus.
-
C99 struct initialization
Error is generated with the foolowing code, which is valide C99:
typedef union
{
struct
{
unsigned int a : 4;
unsigned int b : 4;
unsigned int c : 4;
unsigned int d : 4;
} bits;
unsigned short value;
} My_Value;int main(void)
{
My_Value test[] =
{
{
.bits.a = 2,
.bits.b = 3,
.bits.c = 2,
.bits.d = 3,
},
{
.bits.a = 1,
.bits.b = 1,
.bits.c = 1,
.bits.d = 0,
},
};
return 0;
}4 votesThis issue is corrected in the upcoming PC-lint Plus. If you are encountering an issue with C99 struct initialization in PC-lint or FlexeLint, please contact support for assistance.
-
Have restore at end reset the internal counter of -esym
Right now, this works correctly only for -e#, but very often, programmers make mistakes using -esym as well.
Would be nice to not have to debug those using -voif.
Example:@module foo.cpp
namespace test
{
extern bool bar(void);
extern bool flag;bool foo(void)
{
//the next line is a programmer mistake which is carried on into bar.cpp despite using -restoreatend
//lint -esym(1960,5-14-1)
return flag && bar();
}
}@module bar.cpp
namespace test
{
extern bool foo(void);
extern bool flag;bool bar(void)
{
// Violates 5-14-1 but is not reported due to error in previous module
return flag &&…1 voteOptions encountered within source files no longer affect subsequent source files in the upcoming PC-lint Plus which resolves this issue.
-
make use of multiple cores on modern CPU/OS
Similar to what GNU makes offers with it´s -j switch, large projects would benefit greatly, if LINT was able to scan multiple files simultaneously (e.g. four on a quad core CPU).
33 votesParallel Analysis is available in the upcoming PC-lint Plus.
-
Stop reporting 948 for expressions in C++11 static_assert()'s
Since C++11, static_assert can be used to express conditions which have to be met at compile time and PC-lint claims to support this since version 9.00k.
But even with 9.00L with co-msc110, env-vc10 and au-misra-cpp, the following code will trigger a 948:
static const sizet SOMESIZE = 42U;
staticassert( SOMESIZE < 100U, "..." ); // Triggers Note 948: Operator '<' always evaluates to TrueThis should not be reported, as this is exactly the point of static_assert to always evaluate to true!
8 votesThis issue has been corrected in the upcoming PC-lint Plus.
-
enhancement for error 1762 "Member function could be made const"
The message:
Pages.cpp(206): error 1762: (Info -- Member function 'xxx:yyy(void)' could be made const)could be enhanced to make it easier to type in "const" in both the source and header files:
1. The line number reference should the first line the function and not the function's closing brace
2. add a "error 830: (Info -- Location cited in prior message)" line that references the function's declaration in the header file7 votesThe first part of this request (more useful location for the diagnostic) has been implemented for the upcoming PC-lint Plus. We are declining to implement the second part of the request (adding a supplemental message containing the location of the declaration) but may reconsider if the this is made into a separate suggestion.
-
Support for labels as values (GNU extension)
GNU C / Clang support an extension where the address of a label can be taken as a value and assigned to a variable, and then jumped to using goto.
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.htmlFor example, this small test program:
int main(void)
{
int r;
foo:
r = 4;void *f = &&foo; goto *f; return 0;
}
causes the following errors from FlexeLint:
--- Module: main.c (C)
_
void *f = &&foo;
main.c 8 Error 24: Expected an expression, found '&&'
main.c 8 Error 40: Undeclared identifier 'foo'
_
goto *f;
main.c 11 Error 10: Expecting identifierIs there some combination of…
3 votesThis extension is supported in the upcoming PC-lint Plus.
-
Stop reporting1746 within extern "C" code as its wrong!
In c++ code which is defining a C interface we get lots of 1746 errors. This is lint telling us to use const reference, how is that gonna work in C! These functions are in extern "C" scope so cannot use references. This seems like a bu/omission as of lint 9.0K.
4 votesThe requested behavior has been implemented in the upcoming PC-lint Plus.
-
Extend value tracking for member variables/functions
include <string.h>
//lint -passes(2)
class X
{
int *p;
public:
X(){ p = NULL; }
bool IsValid()const{return p != NULL;}
void Foo()
{
if(IsValid())
*p = 0; // Warning 613: Possible use of null pointer (wrong)
}
void Bar()
{
if(p != NULL)
*p = 0; // no 613 here (ok)
}
};// Value tracking works for global variables (ok)
int pg = NULL;
bool IsValid(const int px)
{
return px != NULL;
}
void Bar()
{
if(IsValid(pg))
*pg = 0;// no 613 here (ok)
}1 voteThis issue has been addressed in the updated value tracking available in the upcoming PC-lint Plus.
-
Implement structure value tracking
Provide basic structure value tracking. Especially for null pointers. Consider the following:
xres->lif=NULL;
foo(xres->lif->stuff);Should flag deference of xres->lif as "known null access"
16 votesStructure member value tracking is available in the upcoming PC-lint Plus.
-
Wrong suggestion on how to export environment variables on Linux
This article explains how to create environment variables on Linux. It wrongly suggests:
export INCLUDE=/usr/local/include;/usr/include
but the correct way is as followed (replace ';' by ':' between paths):
export INCLUDE=/usr/local/include:/usr/include
Best regards
Martin Ettl
1 voteThanks for pointing that out Martin, the article has been corrected.
- Don't see your idea?