Skip to content

Commit

Permalink
feat(#396): fix all qulice offences
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Jul 29, 2024
1 parent b900b8a commit ce750a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
20 changes: 0 additions & 20 deletions src/main/java/com/github/lombrozo/testnames/Cop.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ final class Cop {
*/
private final Project project;

/**
* Parameters for rules.
*/
private final Parameters parameters;

/**
* The law to check the project.
*/
Expand Down Expand Up @@ -81,23 +76,8 @@ final class Cop {
Cop(
final Project project,
final Function<Suspect, Stream<Rule>> law
) {
this(project, new Parameters(), law);
}

/**
* Ctor.
* @param project The project to check.
* @param parameters Parameters for rules.
* @param law The law to check the project.
*/
private Cop(
final Project project,
final Parameters parameters,
final Function<Suspect, Stream<Rule>> law
) {
this.project = project;
this.parameters = parameters;
this.law = law;
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/github/lombrozo/testnames/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ private Parameters(final Map<String, ?> params) {
*/
public OptionalInt intValue(final String name) {
final OptionalInt result;
if (!this.params.containsKey(name)) {
result = OptionalInt.empty();
} else {
if (this.params.containsKey(name)) {
final Object value = this.params.get(name);
if (!(value instanceof Integer)) {
throw new IllegalArgumentException(
Expand All @@ -74,6 +72,8 @@ public OptionalInt intValue(final String name) {
);
}
result = OptionalInt.of(Integer.class.cast(value));
} else {
result = OptionalInt.empty();
}
return result;
}
Expand All @@ -83,13 +83,13 @@ public OptionalInt intValue(final String name) {
* @param params Parameters pairs like "name", "value", "name2", "value2".
* @return Map.
*/
private static Map<String, ?> fromArray(final Object[] params) {
private static Map<String, ?> fromArray(final Object... params) {
if (params.length % 2 != 0) {
throw new IllegalArgumentException("Parameters list should be even");
}
final Map<String, Object> res = new HashMap<>(0);
for (int i = 0; i < params.length; i += 2) {
res.put((String) params[i], params[i + 1]);
for (int index = 0; index < params.length; index += 2) {
res.put((String) params[index], params[index + 1]);
}
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ void findsNoValue() {
Matchers.is(false)
);
}
}
}

1 comment on commit ce750a5

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on ce750a5 Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 393-9c344e41 disappeared from src/main/java/com/github/lombrozo/testnames/Cop.java), that's why I closed #396. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.