Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pieter Koopman
Personal Prof public repository
Commits
d2cd71d1
Commit
d2cd71d1
authored
May 07, 2020
by
Rick van der Wal
Browse files
Added warnings for eredundant access momodifiers for enums or interfaces
parent
ddd44f6f
Changes
34
Hide whitespace changes
Inline
Side-by-side
src/CodingRules.rsc
View file @
d2cd71d1
...
...
@@ -16,8 +16,8 @@ set[Message] allCodingRules(M3 model)
+ ps_attribute_names_lowercase(model)
+ ps_all_caps_constant_names(model)
+ ps_explicit_access_modifiers(model)
//
+ ps_no_enum_modifier(model)
//
+ ps_no_interface_modifier(model)
+ ps_no_enum_modifier(model)
+ ps_no_interface_modifier(model)
+ ps_public_attributes(model)
// Redundant for Main, but useful for the tests
+ modelErrors(model)
...
...
@@ -75,27 +75,29 @@ set[Message] ps_explicit_access_modifiers(M3 model)
};
}
//set[Message] ps_no_enum_modifier(M3 model)
//{
// set[loc] artifactsOfInterest = range(declaredMethods(model));
// return
// { error("Private access modifiers for enum constructors are redundant", thing)
// | thing <- artifactsOfInterest
// // & is set intersection
// , !isEmpty(model.modifiers[thing] & {\private()}) &&
// };
//}
//
//set[Message] ps_no_interface_modifier(M3 model)
//{
// set[loc] artifactsOfInterest = range(declaredMethods(model));
// return
// { error("Public access modifiers for interface methods are redundant", thing)
// | thing <- artifactsOfInterest
// // & is set intersection
// , !isEmpty(model.modifiers[thing] & {\public()}) &&
// };
//}
set[Message] ps_no_enum_modifier(M3 model)
{
set[loc] artifactsOfInterest = range(declaredMethods(model));
return
{ error("Private access modifiers for enum constructors are redundant", thing)
| thing <- artifactsOfInterest
// & is set intersection
, !isEmpty(model.modifiers[thing] & {\private()})
&& {1 | enum <- enums(model), thing in constructors(model, enum)} != {}
};
}
set[Message] ps_no_interface_modifier(M3 model)
{
set[loc] artifactsOfInterest = range(declaredMethods(model));
return
{ error("Public access modifiers for interface methods are redundant", thing)
| thing <- artifactsOfInterest
// & is set intersection
, !isEmpty(model.modifiers[thing] & {\public()})
&& {1 | interface <- interfaces(model), thing in methods(model, interface)} != {}
};
}
// If an attribute is public, it must be final
set[Message] ps_public_attributes(M3 model) =
...
...
src/test-data/assignment-snake-example-solution/src/snake/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dX
,
dY
;
private
Direction
(
int
dX
,
int
dY
)
{
Direction
(
int
dX
,
int
dY
)
{
this
.
dX
=
dX
;
this
.
dY
=
dY
;
}
...
...
src/test-data/assignment-snake-example-solution/src/snake/Snake.java
View file @
d2cd71d1
...
...
@@ -9,7 +9,7 @@ import java.util.List;
public
class
Snake
extends
Segment
{
public
interface
SnakeSegmentListener
{
public
void
onNewSegment
(
Segment
segment
);
void
onNewSegment
(
Segment
segment
);
}
private
Direction
direction
=
Direction
.
RIGHT
;
...
...
src/test-data/assignment-snake-graphics-in-inner-class/src/snake/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dX
,
dY
;
private
Direction
(
int
dX
,
int
dY
)
{
Direction
(
int
dX
,
int
dY
)
{
this
.
dX
=
dX
;
this
.
dY
=
dY
;
}
...
...
src/test-data/assignment-snake-graphics-in-inner-class/src/snake/Snake.java
View file @
d2cd71d1
...
...
@@ -9,7 +9,7 @@ import java.util.List;
public
class
Snake
extends
Segment
{
public
interface
SnakeSegmentListener
{
public
void
onNewSegment
(
Segment
segment
);
void
onNewSegment
(
Segment
segment
);
}
private
Direction
direction
=
Direction
.
RIGHT
;
...
...
src/test-data/assignment-snake-graphics-not-in-view/src/snake/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dX
,
dY
;
private
Direction
(
int
dX
,
int
dY
)
{
Direction
(
int
dX
,
int
dY
)
{
this
.
dX
=
dX
;
this
.
dY
=
dY
;
}
...
...
src/test-data/assignment-snake-graphics-not-in-view/src/snake/Snake.java
View file @
d2cd71d1
...
...
@@ -9,7 +9,7 @@ import java.util.List;
public
class
Snake
extends
Segment
{
public
interface
SnakeSegmentListener
{
public
void
onNewSegment
(
Segment
segment
);
void
onNewSegment
(
Segment
segment
);
}
private
Direction
direction
=
Direction
.
RIGHT
;
...
...
src/test-data/assignment-snake-input-in-inner-class/src/snake/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dX
,
dY
;
private
Direction
(
int
dX
,
int
dY
)
{
Direction
(
int
dX
,
int
dY
)
{
this
.
dX
=
dX
;
this
.
dY
=
dY
;
}
...
...
src/test-data/assignment-snake-input-in-inner-class/src/snake/Snake.java
View file @
d2cd71d1
...
...
@@ -9,7 +9,7 @@ import java.util.List;
public
class
Snake
extends
Segment
{
public
interface
SnakeSegmentListener
{
public
void
onNewSegment
(
Segment
segment
);
void
onNewSegment
(
Segment
segment
);
}
private
Direction
direction
=
Direction
.
RIGHT
;
...
...
src/test-data/assignment-snake-input-not-in-controller/src/snake/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dX
,
dY
;
private
Direction
(
int
dX
,
int
dY
)
{
Direction
(
int
dX
,
int
dY
)
{
this
.
dX
=
dX
;
this
.
dY
=
dY
;
}
...
...
src/test-data/assignment-snake-input-not-in-controller/src/snake/Snake.java
View file @
d2cd71d1
...
...
@@ -12,7 +12,7 @@ import java.util.List;
public
class
Snake
extends
Segment
implements
EventHandler
<
KeyEvent
>
{
public
interface
SnakeSegmentListener
{
public
void
onNewSegment
(
Segment
segment
);
void
onNewSegment
(
Segment
segment
);
}
private
Direction
direction
=
Direction
.
RIGHT
;
...
...
src/test-data/assignment-snake-start/src/snake/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dX
,
dY
;
private
Direction
(
int
dX
,
int
dY
)
{
Direction
(
int
dX
,
int
dY
)
{
this
.
dX
=
dX
;
this
.
dY
=
dY
;
}
...
...
src/test-data/assignment-snake-start/src/snake/Snake.java
View file @
d2cd71d1
...
...
@@ -9,7 +9,7 @@ import java.util.List;
public
class
Snake
extends
Segment
{
public
interface
SnakeSegmentListener
{
public
void
onNewSegment
(
Segment
segment
);
void
onNewSegment
(
Segment
segment
);
}
private
Direction
direction
=
Direction
.
RIGHT
;
...
...
src/test-data/assignment03-geometric-example-solution/src/geometric/Geometric.java
View file @
d2cd71d1
...
...
@@ -7,20 +7,20 @@ package geometric;
*/
public
interface
Geometric
extends
Comparable
<
Geometric
>
{
public
double
leftBorder
();
double
leftBorder
();
public
double
rightBorder
();
double
rightBorder
();
public
double
bottomBorder
();
double
bottomBorder
();
public
double
topBorder
();
double
topBorder
();
public
double
areaObject
();
double
areaObject
();
public
void
moveObject
(
double
dx
,
double
dy
);
void
moveObject
(
double
dx
,
double
dy
);
@Override
public
default
int
compareTo
(
Geometric
x
)
{
default
int
compareTo
(
Geometric
x
)
{
if
(
this
.
areaObject
()
<
x
.
areaObject
())
{
return
-
1
;
}
...
...
src/test-data/assignment05-expressions-example-solution/src/assignment05/Expression.java
View file @
d2cd71d1
...
...
@@ -10,11 +10,11 @@ import java.util.Map;
*/
public
abstract
interface
Expression
{
public
abstract
String
toString
();
abstract
String
toString
();
public
abstract
double
eval
(
Map
<
String
,
Double
>
env
);
abstract
double
eval
(
Map
<
String
,
Double
>
env
);
public
abstract
Expression
partialEval
();
abstract
Expression
partialEval
();
public
static
final
Map
<
String
,
Double
>
EMPTY_ENV
=
new
HashMap
<>();
}
src/test-data/assignment06-sliding-game-example-solution/src/assignment06/Configuration.java
View file @
d2cd71d1
...
...
@@ -5,13 +5,13 @@ import java.util.LinkedList;
import
java.util.List
;
public
interface
Configuration
extends
Comparable
<
Configuration
>
{
public
abstract
Configuration
getParent
();
abstract
Configuration
getParent
();
public
Collection
<
Configuration
>
successors
();
Collection
<
Configuration
>
successors
();
public
boolean
isSolution
();
boolean
isSolution
();
public
default
List
<
Configuration
>
pathFromRoot
()
{
default
List
<
Configuration
>
pathFromRoot
()
{
List
<
Configuration
>
result
=
new
LinkedList
<>();
Configuration
node
=
this
;
while
(
node
!=
null
)
...
...
src/test-data/assignment06-sliding-game-example-solution/src/assignment06/Direction.java
View file @
d2cd71d1
...
...
@@ -8,7 +8,7 @@ public enum Direction {
private
final
int
dx
,
dy
;
private
Direction
(
int
dx
,
int
dy
)
{
Direction
(
int
dx
,
int
dy
)
{
this
.
dx
=
dx
;
this
.
dy
=
dy
;
}
...
...
src/test-data/assignment07-quadtrees-example-solution/src/assignment07/QuadTreeNode.java
View file @
d2cd71d1
...
...
@@ -4,10 +4,10 @@ import java.io.Writer;
public
interface
QuadTreeNode
{
public
void
fillBitmap
(
int
x
,
int
y
,
int
width
,
Bitmap
bitmap
);
void
fillBitmap
(
int
x
,
int
y
,
int
width
,
Bitmap
bitmap
);
public
void
writeNode
(
Writer
out
);
void
writeNode
(
Writer
out
);
public
boolean
sameLeaf
(
QuadTreeNode
other_node
);
boolean
sameLeaf
(
QuadTreeNode
other_node
);
}
src/test-data/assignment07-quadtrees-start/src/assignment07/QuadTreeNode.java
View file @
d2cd71d1
...
...
@@ -4,7 +4,7 @@ package assignment07;
import
java.io.Writer
;
public
interface
QuadTreeNode
{
public
void
fillBitmap
(
int
x
,
int
y
,
int
width
,
Bitmap
bitmap
);
void
fillBitmap
(
int
x
,
int
y
,
int
width
,
Bitmap
bitmap
);
public
void
writeNode
(
Writer
out
);
void
writeNode
(
Writer
out
);
}
src/test-data/assignment11-no-use-strategy/src/ast/BinOp.java
View file @
d2cd71d1
...
...
@@ -23,7 +23,7 @@ public enum BinOp implements BinaryOperator<Boolean> {
private
int
prio
;
private
String
string
;
private
BinOp
(
int
prio
,
String
string
)
{
BinOp
(
int
prio
,
String
string
)
{
this
.
prio
=
prio
;
this
.
string
=
string
;
}
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
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