Commit d2cd71d1 authored by Rick van der Wal's avatar Rick van der Wal
Browse files

Added warnings for eredundant access momodifiers for enums or interfaces

parent ddd44f6f
......@@ -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) =
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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<>();
}
......@@ -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 )
......
......@@ -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;
}
......
......@@ -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);
}
......@@ -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);
}
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment