Skip to content

Commit 3324bfb

Browse files
committed
C++: Fix long comments without * on each line
Comments like these will make the autoformatter produce bad indentation. For the record (not for explainability), these issues were found with git grep -P -A1 '^( */\*| +\*( |$))(.(?!\*/))*$' cpp/ql/src/'**/*.ql*' |grep -B10 'qll\?- [^*]*$'
1 parent 44aca8a commit 3324bfb

4 files changed

Lines changed: 59 additions & 54 deletions

File tree

cpp/ql/src/jsf/4.09 Style/AV Rule 63.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ predicate diffBeginBegin(Expr lhs, Expr rhs, int length) {
4747
/*
4848
* Unary postfix operations: PostfixDecrExpr, PostfixIncrExpr
4949
* Unary prefix operations: PrefixIncrExpr, PrefixDecrExpr, ComplementExpr, NotExpr,
50-
UnaryMinusExpr, UnaryPlusExpr, AddressOfExpr, PointerDereferenceExpr
50+
* UnaryMinusExpr, UnaryPlusExpr, AddressOfExpr, PointerDereferenceExpr
5151
*/
5252

5353
from Expr err

cpp/ql/src/jsf/4.10 Classes/AV Rule 73.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import cpp
1212

1313
/* bug finding approach: look for no-argument constructors that set a certain field x,
14-
such that every member function reading x also contains a comparison involving x as
15-
part of an if statement; the host class should not be used in an array type or as
16-
part of an array new, it should not be used in a template instantiation, and it should
17-
not be a virtual base class */
14+
* such that every member function reading x also contains a comparison involving x as
15+
* part of an if statement; the host class should not be used in an array type or as
16+
* part of an array new, it should not be used in a template instantiation, and it should
17+
* not be a virtual base class */
1818

1919
from Constructor c, MemberVariable f
2020
where c.fromSource() and

cpp/ql/src/jsf/4.24 Control Flow Structures/AV Rule 191.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import cpp
1111

1212
/* TODO: "The break statement may be used to break out of a single loop provided
13-
the alternative would obscure or otherwise significantly complicate the
14-
control logic." */
13+
* the alternative would obscure or otherwise significantly complicate the
14+
* control logic." */
1515

1616
// whether t is the last statement of s, possibly peeling off blocks
1717
predicate isTerminatingStmt(Stmt s, Stmt t) {

cpp/ql/src/semmle/code/cpp/metrics/MetricClass.qll

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,37 @@ class MetricClass extends Class {
7676
dependsOnClassSimple(this, result)
7777
}
7878

79-
/* -------- HENDERSON-SELLERS LACK OF COHESION IN METHODS -------- */
80-
81-
/* The aim of this metric is to try and determine whether a class
82-
represents one abstraction (good) or multiple abstractions (bad).
83-
If a class represents multiple abstractions, it should be split
84-
up into multiple classes.
85-
86-
In the Henderson-Sellers method, this is measured as follows:
87-
M = set of methods in class
88-
F = set of fields in class
89-
r(f) = number of methods that access field f
90-
<r> = mean of r(f) over f in F
91-
The lack of cohesion is then given by
92-
93-
<r> - |M|
94-
---------
95-
1 - |M|
96-
97-
We follow the Eclipse metrics plugin by restricting M to methods
98-
that access some field in the same class, and restrict F to
99-
fields that are read by methods in the same class.
100-
101-
Classes where the value of this metric is higher than 0.9 ought
102-
to be scrutinised for possible splitting. Here is a query
103-
to find such classes:
104-
105-
from MetricRefType t, float loc
106-
where loc = t.getLackOfCohesionHS() and loc > 0.9
107-
select t, loc order by loc desc
108-
*/
79+
/*
80+
* -------- HENDERSON-SELLERS LACK OF COHESION IN METHODS --------
81+
82+
* The aim of this metric is to try and determine whether a class
83+
* represents one abstraction (good) or multiple abstractions (bad).
84+
* If a class represents multiple abstractions, it should be split
85+
* up into multiple classes.
86+
87+
* In the Henderson-Sellers method, this is measured as follows:
88+
* M = set of methods in class
89+
* F = set of fields in class
90+
* r(f) = number of methods that access field f
91+
* <r> = mean of r(f) over f in F
92+
* The lack of cohesion is then given by
93+
94+
* <r> - |M|
95+
* ---------
96+
* 1 - |M|
97+
98+
* We follow the Eclipse metrics plugin by restricting M to methods
99+
* that access some field in the same class, and restrict F to
100+
* fields that are read by methods in the same class.
101+
102+
* Classes where the value of this metric is higher than 0.9 ought
103+
* to be scrutinised for possible splitting. Here is a query
104+
* to find such classes:
105+
106+
* from MetricRefType t, float loc
107+
* where loc = t.getLackOfCohesionHS() and loc > 0.9
108+
* select t, loc order by loc desc
109+
*/
109110

110111
/** Holds if `func` accesses field `f` defined in the same type. */
111112
predicate accessesLocalField(Function func, Field f) {
@@ -143,23 +144,23 @@ class MetricClass extends Class {
143144
)
144145
}
145146

146-
/* -------- CHIDAMBER AND KEMERER LACK OF COHESION IN METHODS ------------ */
147+
/*
148+
* -------- CHIDAMBER AND KEMERER LACK OF COHESION IN METHODS ------------
147149
148-
/* The aim of this metric is to try and determine whether a class
149-
represents one abstraction (good) or multiple abstractions (bad).
150-
If a class represents multiple abstractions, it should be split
151-
up into multiple classes.
150+
* The aim of this metric is to try and determine whether a class
151+
* represents one abstraction (good) or multiple abstractions (bad).
152+
* If a class represents multiple abstractions, it should be split
153+
* up into multiple classes.
152154
153-
In the Chidamber and Kemerer method, this is measured as follows:
154-
n1 = number of pairs of distinct methods in a class that do *not*
155-
have at least one commonly accessed field
156-
n2 = number of pairs of distinct methods in a class that do
157-
have at least one commonly accessed field
158-
lcom = ((n1 - n2)/2 max 0)
155+
* In the Chidamber and Kemerer method, this is measured as follows:
156+
* n1 = number of pairs of distinct methods in a class that do *not*
157+
* have at least one commonly accessed field
158+
* n2 = number of pairs of distinct methods in a class that do
159+
* have at least one commonly accessed field
160+
* lcom = ((n1 - n2)/2 max 0)
159161
160-
We divide by 2 because each pair (m1,m2) is counted twice in n1 and n2.
161-
162-
*/
162+
* We divide by 2 because each pair (m1,m2) is counted twice in n1 and n2.
163+
*/
163164

164165
/** Holds if `f` should be excluded from the CK cohesion computation. */
165166
predicate ignoreLackOfCohesionCK(Function f) {
@@ -206,7 +207,9 @@ class MetricClass extends Class {
206207
)
207208
}
208209

209-
/* ----------------- RESPONSE FOR A CLASS --------------------------------- */
210+
/*
211+
* ----------------- RESPONSE FOR A CLASS ---------------------------------
212+
*/
210213

211214
/**
212215
* Gets the _response_ for this class. This estimates the number of
@@ -217,7 +220,9 @@ class MetricClass extends Class {
217220
result = sum(MemberFunction f | f.getDeclaringType()=this | count(Call call | call.getEnclosingFunction() = f))
218221
}
219222

220-
/* ----------------- SPECIALIZATION INDEX -------------------------------- */
223+
/*
224+
* ----------------- SPECIALIZATION INDEX --------------------------------
225+
*/
221226

222227
/**
223228
* Gets a function that should be excluded when reporting the number of
@@ -259,7 +264,7 @@ class MetricClass extends Class {
259264
}
260265

261266
/*
262-
* HALSTEAD METRICS
267+
* ----------------- HALSTEAD METRICS ------------------------------------
263268
*/
264269

265270
/**

0 commit comments

Comments
 (0)