Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Roxane MARECHAL
Source Code Analyzer
Commits
75f0e0a6
Commit
75f0e0a6
authored
Dec 22, 2019
by
Roxane Kang Maréchal
Browse files
Improved comments related to missing break in switch
parent
b48745b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/atl/analysis.atl
View file @
75f0e0a6
...
...
@@ -161,10 +161,8 @@ helper def: allMeasures(project : java!Model): Set(smm!Measure) =
--- Creates an instance of Measure for the switch statement missing one or more break statements
-- To test, use input model : missing-break-in-switch.xmi
-- #TODO: rename rule
rule createMeasureForMissingBreakInSwitch(ss: java!SwitchStatement) {
--- Creates an instance of Measure for the switch statement missing one or more break/return statements
rule MeasureMissingBreakInSwitch(ss: java!SwitchStatement) {
to
om: smm!ObservedMeasure (
measure <- missingBreakInSwitch,
...
...
@@ -2038,7 +2036,7 @@ helper def: numberFieldsInClasse(s:java!ClassDeclaration) : Integer =
-- Return the number of FieldDeclaration in a class.
s.bodyDeclarations-> select(r | r.oclIsTypeOf(java!FieldDeclaration))->size();
--- Returns the number of breaks of the switch statement passed in parameter
--- Returns the number of breaks
/return/continue/throw
of the switch statement passed in parameter
helper def: nbBreakStatementOfASwitchStatement(ss:java!SwitchStatement) : Integer =
ss.statements->select(each | each.oclIsTypeOf(java!BreakStatement)).size()
;
...
...
src/main/atl/errorProne.atl
View file @
75f0e0a6
...
...
@@ -2,14 +2,14 @@ library errorProne;
---------------------------------- Missing break in switch---------------------------------------------
-- Returns a set of measures for e
ach
switch statement
that violates the rule : missing break in switch
--
-
Returns a set of measures for e
very
switch statement
without break or return statements for each case option
helper def: missingBreakInSwitch(): Set(smm!Measure) =
java!SwitchStatement.allInstances()
-> select (switchStatement | thisModule.switchStatementContainsMissingBreaks(switchStatement))
-> collect (switchStatement | thisModule.
create
Measure
For
MissingBreakInSwitch(switchStatement))
-> collect (switchStatement | thisModule.MeasureMissingBreakInSwitch(switchStatement))
;
-- Returns true if the switch statement contains missing breaks, false otherwise
--
-
Returns true if the switch statement contains missing breaks
or return
, false otherwise
helper def: switchStatementContainsMissingBreaks(ss: java!SwitchStatement): Boolean =
-- If the number of switch cases (omitting those that empty => indicates intentional fallout) is bigger than
-- the number of break statements => we don't have a break statement for every switch case
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment