FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/java/ql/src/Performance/InefficientOutputStream.ql at main · github/codeql · GitHub
github
codeql
Repository navigation
Code
Issues
1k
(1k)
Pull requests
473
(473)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
java
/
ql
/
src
/
Performance
/
InefficientOutputStream.ql
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (40 loc) · 1.4 KB
Breadcrumbs
codeql
/
java
/
ql
/
src
/
Performance
/
InefficientOutputStream.ql
Copy path
File metadata and controls
43 lines (40 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @name Inefficient output stream
* @description Using the default implementation of 'write(byte[],int,int)'
* provided by 'java.io.OutputStream' is very inefficient.
* @kind problem
* @problem.severity warning
* @precision very-high
* @id java/inefficient-output-stream
* @tags quality
* reliability
* performance
* efficiency
*/
import
java
class
InefficientWriteBytes
extends
Class
{
InefficientWriteBytes
(
)
{
this
.
hasQualifiedName
(
"java.io"
,
"OutputStream"
)
or
this
.
hasQualifiedName
(
"java.io"
,
"FilterOutputStream"
)
}
}
from
Class
c
,
Method
m
where
not
c
.
isAbstract
(
)
and
not
c
instanceof
InefficientWriteBytes
and
c
.
getASupertype
(
)
instanceof
InefficientWriteBytes
and
c
.
getAMethod
(
)
=
m
and
m
.
getName
(
)
=
"write"
and
m
.
getNumberOfParameters
(
)
=
1
and
m
.
getParameterType
(
0
)
.
(
PrimitiveType
)
.
getName
(
)
=
"int"
and
exists
(
Method
m2
|
c
.
inherits
(
m2
)
|
m2
.
getName
(
)
=
"write"
and
m2
.
getNumberOfParameters
(
)
=
3
and
m2
.
getDeclaringType
(
)
instanceof
InefficientWriteBytes
)
and
// If that method doesn't call write itself, then we don't have a problem.
// This is the case is some dummy implementations.
exists
(
MethodCall
ma
|
ma
.
getEnclosingCallable
(
)
=
m
|
ma
.
getMethod
(
)
.
getName
(
)
=
"write"
)
select
c
,
"This class extends 'java.io.OutputStream' and implements $@, but does not override 'write(byte[],int,int)'."
,
m
,
m
.
getName
(
)
Back
|
FazBrowse Home
|
New Git URL