TscanCode V2.14.24 released · s20101192/TscanCode@4db6cdd · GitHub
Skip to content

Commit 4db6cdd

Browse files
author
quarkgit
committed
TscanCode V2.14.24 released
1 parent 76abd43 commit 4db6cdd

323 files changed

Lines changed: 131693 additions & 130312 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 9 deletions

README.md

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
1-
# **TscanCode**
2-
3-
![Release version](https://img.shields.io/badge/version-2.11.27-blue.svg)
4-
5-
## A fast and accurate static analysis solution for C/C++, C#, Lua codes
6-
7-
Tencent is pleased to support the open source community by making TscanCode available.
8-
9-
Copyright (C) 2017 Tencent company and TscanCode Team. All rights reserved.
10-
11-
## Introduction
12-
13-
TscanCode is devoted to help programmers to find out code defects at the very beginning.
14-
* TscanCode supports multi-language: `C/C++`, `C#` and `Lua` codes;
15-
* TscanCode is `fast` and `accurate`, The performance can be 200K lines per minute and the accuracy rate is about 90%;
16-
* TscanCode is `easy to use`, It doesn't require strict compiling enviroment and one single command can make it work;
17-
* TscanCode is `extensible`, you can implement your own checks with TscanCode.
18-
19-
## Highlights in v2.11.27 (2017-12-01)
20-
* Add new check `CS_UnityMessgeSpellWrong`, check typo errors of Unity message functions;
21-
* Add new check `lua_VarSpellWrongError` and `lua_KeywordSpellWrongError`, check typo errors of Lua variable and keyword;
22-
23-
For other changes please refer to [change log](CHANGELOG.md).
24-
25-
## Compiling
26-
27-
Any C++11 compiler should work. For compilers with partial C++11 support it may work. If your compiler has the C++11 features that are available in Visual Studio 2015 then it will work. If nullptr is not supported by your compiler then this can be emulated using the header lib/cxx11emu.h.
28-
29-
There are multiple compilation choices:
30-
* Windows: Visual Studio (Visual Studio 2015 and above)
31-
* Linux: g++ 4.6 (or later)
32-
* Mac: clang++
33-
34-
### Visual Studio
35-
36-
Use the tscancode.sln file. The file is configured for Visual Studio 2015, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.
37-
38-
Select option `Release` to build release version.
39-
40-
### g++ or clang++
41-
42-
Simple build (no dependencies):
43-
44-
```shell
45-
make
46-
```
47-
48-
## Usage at a glance
49-
50-
This simple example contains a potential null pointer defect. Checking if p is null indicates that p might be null, so dereferencing p `*p` is not safe outside the `if-scope`.
51-
52-
~~~~~~~~~~cpp
53-
// func.cpp
54-
void func(int* p) {
55-
if(p == NULL) {
56-
printf("p is null!");
57-
}
58-
59-
printf("p is %d", *p);
60-
}
61-
~~~~~~~~~~
62-
63-
Run TscanCode:
64-
```shell
65-
./tscancode --xml func.cpp 2>result.xml
66-
```
67-
Error list, result.xml:
68-
69-
~~~~~~~~~~xml
70-
<?xml version="1.0" encoding="UTF-8"?>
71-
<results>
72-
<error file="func.cpp" line="7" id="nullpointer" subid="dereferenceAfterCheck" severity="error"
73-
msg="Comparing [p] to null at line 3 implies [p] might be null. Dereferencing null pointer [p]." />
74-
</results>
75-
~~~~~~~~~~
76-
77-
There are more examples:
78-
* [CPP samples](samples/cpp);
79-
* [C# samples](samples/csharp);
80-
* [Lua samples](samples/lua);
81-
82-
For now, codes under [trunk](trunk) are only for TscanCode `CPP` version, `C#` and `Lua` version are in the internal review process. Sorry for the inconvenience.
83-
1+
# **TscanCode**
2+
3+
![Release version](https://img.shields.io/badge/version-2.11.27-blue.svg)
4+
5+
## A fast and accurate static analysis solution for C/C++, C#, Lua codes
6+
7+
Tencent is pleased to support the open source community by making TscanCode available.
8+
9+
Copyright (C) 2017 Tencent company and TscanCode Team. All rights reserved.
10+
11+
## Introduction
12+
13+
TscanCode is devoted to help programmers to find out code defects at the very beginning.
14+
* TscanCode supports multi-language: `C/C++`, `C#` and `Lua` codes;
15+
* TscanCode is `fast` and `accurate`, The performance can be 200K lines per minute and the accuracy rate is about 90%;
16+
* TscanCode is `easy to use`, It doesn't require strict compiling enviroment and one single command can make it work;
17+
* TscanCode is `extensible`, you can implement your own checks with TscanCode.
18+
19+
## Highlights in v2.11.27 (2017-12-01)
20+
* Add new check `CS_UnityMessgeSpellWrong`, check typo errors of Unity message functions;
21+
* Add new check `lua_VarSpellWrongError` and `lua_KeywordSpellWrongError`, check typo errors of Lua variable and keyword;
22+
23+
For other changes please refer to [change log](CHANGELOG.md).
24+
25+
## Compiling
26+
27+
Any C++11 compiler should work. For compilers with partial C++11 support it may work. If your compiler has the C++11 features that are available in Visual Studio 2015 then it will work. If nullptr is not supported by your compiler then this can be emulated using the header lib/cxx11emu.h.
28+
29+
There are multiple compilation choices:
30+
* Windows: Visual Studio (Visual Studio 2015 and above)
31+
* Linux: g++ 4.6 (or later)
32+
* Mac: clang++
33+
34+
### Visual Studio
35+
36+
Use the tsancode.sln file. The file is configured for Visual Studio 2015, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.
37+
38+
Select option `Release` to build release version.
39+
40+
### g++ or clang++
41+
42+
Simple build (no dependencies):
43+
44+
```shell
45+
make
46+
```
47+
48+
## Usage at a glance
49+
50+
This simple example contains a potential null pointer defect. Checking if p is null indicates that p might be null, so dereferencing p `*p` is not safe outside the `if-scope`.
51+
52+
~~~~~~~~~~cpp
53+
// func.cpp
54+
void func(int* p) {
55+
if(p == NULL) {
56+
printf("p is null!");
57+
}
58+
59+
printf("p is %d", *p);
60+
}
61+
~~~~~~~~~~
62+
63+
Run TscanCode:
64+
```shell
65+
./tscancode --xml func.cpp 2>result.xml
66+
```
67+
Error list, result.xml:
68+
69+
~~~~~~~~~~xml
70+
<?xml version="1.0" encoding="UTF-8"?>
71+
<results>
72+
<error file="func.cpp" line="7" id="nullpointer" subid="dereferenceAfterCheck" severity="error"
73+
msg="Comparing [p] to null at line 3 implies [p] might be null. Dereferencing null pointer [p]." />
74+
</results>
75+
~~~~~~~~~~
76+
77+
There are more examples:
78+
* [CPP samples](samples/cpp);
79+
* [C# samples](samples/csharp);
80+
* [Lua samples](samples/lua);
81+
82+
For now, codes under [trunk](trunk) are only for TscanCode `CPP` version, `C#` and `Lua` version are in the internal review process. Sorry for the inconvenience.
83+
-5.86 MB
Binary file not shown.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
void Demo(int i, int j)
2-
{
3-
// 正确的写法应该是:long long t = (long long)i * j;
4-
long long ll = i * j;
1+
void Demo(int i, int j)
2+
{
3+
// 正确的写法应该是:long long t = (long long)i * j;
4+
long long ll = i * j;
55
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
char buf[10];
2-
3-
void Demo(int i)
4-
{
5-
// i可能等于10,下标保护条件存在漏洞
6-
if(i < 0 || i > 10)
7-
return;
8-
9-
// i等于10时,数组越界
10-
buf[i] = 'Q';
1+
char buf[10];
2+
3+
void Demo(int i)
4+
{
5+
// i可能等于10,下标保护条件存在漏洞
6+
if(i < 0 || i > 10)
7+
return;
8+
9+
// i等于10时,数组越界
10+
buf[i] = 'Q';
1111
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
void Demo(int b)
2-
{
3-
int max = 5;
4-
int a[10];
5-
if (b > 0)
6-
{
7-
max = 10;
8-
}
9-
10-
// max在b>0的时候等于10,造成数组越界
11-
a[max] = max;
1+
void Demo(int b)
2+
{
3+
int max = 5;
4+
int a[10];
5+
if (b > 0)
6+
{
7+
max = 10;
8+
}
9+
10+
// max在b>0的时候等于10,造成数组越界
11+
a[max] = max;
1212
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
void Demo( int index)
2-
{
3-
char buf[10] = {0};
4-
// 先使用index作为数组下标再判定index的取值范围,不符合逻辑
5-
if( buf[index] > 0 && index < INDEX)
6-
return;
1+
void Demo( int index)
2+
{
3+
char buf[10] = {0};
4+
// 先使用index作为数组下标再判定index的取值范围,不符合逻辑
5+
if( buf[index] > 0 && index < INDEX)
6+
return;
77
}

samples/cpp/assignif.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
void Demo(int x)
2-
{
3-
int y = x & 4;
4-
if (y == 3) //条件总是不成立
5-
{
6-
}
1+
void Demo(int x)
2+
{
3+
int y = x & 4;
4+
if (y == 3) //条件总是不成立
5+
{
6+
}
77
}

samples/cpp/assignmentinassert.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
void Demo()
2-
{
3-
int i=0;
4-
// assert函数里面进行赋值操作,存在风险
5-
assert(i=5);
1+
void Demo()
2+
{
3+
int i=0;
4+
// assert函数里面进行赋值操作,存在风险
5+
assert(i=5);
66
}

samples/cpp/autovar.cpp

Lines changed: 5 additions & 5 deletions

0 commit comments

Comments
 (0)