Skip to content

Commit

Permalink
Merge pull request #623 from refinedmods/fix/NO-ISSUE/cleanup
Browse files Browse the repository at this point in the history
style: cleanup
  • Loading branch information
raoulvdberge authored Jul 14, 2024
2 parents 285cfe5 + 3e02db0 commit 13c41ea
Show file tree
Hide file tree
Showing 125 changed files with 251 additions and 771 deletions.
3 changes: 2 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ These are the most important things to know before contributing (also explained
- Branch names must be formatted correctly. The format is `{category}/GH-{issue number}/{lowercase-description}`.
Category must match a
category [used in our Commitlint config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum).
You can also use `NO-ISSUE` instead of a GitHub issue number.
- We use [Checkstyle](https://checkstyle.sourceforge.io/) in our build workflow to validate coding style. It is
recommended to import the [config/checkstyle/checkstyle.xml](../config/checkstyle/checkstyle.xml)
or [config/intellij-code-style.xml](../config/intellij-code-style.xml) file into your
Expand Down Expand Up @@ -47,7 +48,7 @@ Because we use merge commits when merging a PR, branch names will be part of the
branch names must follow a certain standard.

The format is `{category}/GH-{issue number}/{lowercase-description}` and a branch name can be maximum 50 characters of
length.
length. You can also use `NO-ISSUE` instead of a GitHub issue number.

Category must match a
category [used in our Commitlint config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum).
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#file: noinspection YAMLSchemaValidation,YAMLSchemaValidation
blank_issues_enabled: true
contact_links:
- name: Discord Community Support
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
types: [ opened, synchronize, reopened ]
jobs:
build:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
with:
gametests: true
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
type: string
jobs:
draft:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
with:
release-type: ${{ inputs.release-type }}
version-number-override: ${{ inputs.version-number-override }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-for-unsupported-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ labeled, unlabeled, reopened ]
jobs:
unsupported-labeler:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- closed
jobs:
publish-release:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
secrets: inherit
with:
project-name: 'Refined Storage'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/resolved-issue-locking.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Lock resolved issues and PRs
on:
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * 1'
jobs:
lock:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
2 changes: 1 addition & 1 deletion .github/workflows/validate-branch-name.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate branch name
on: [ pull_request ]
jobs:
validate-branch-name:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
2 changes: 1 addition & 1 deletion .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ on:
types: [ opened, synchronize, reopened, ready_for_review, labeled, unlabeled ]
jobs:
validate-changelog:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
2 changes: 1 addition & 1 deletion .github/workflows/validate-commit-messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Validate commit messages
on: [ pull_request ]
jobs:
validate-commit-messages:
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].4
uses: refinedmods/refinedarchitect/.github/workflows/[email protected].6
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ eclipse/
*.iws
.idea/
!.idea/dictionaries/refinedstorage.xml
!.idea/inspectionProfiles/refinedstorage.xml
!.idea/icon.png
out/
/bin/
Expand Down
31 changes: 31 additions & 0 deletions .idea/dictionaries/refinedstorage.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/inspectionProfiles/refinedstorage.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!--suppress HtmlDeprecatedAttribute -->
<div align="center">
<img width="280" alt="Refined Storage logo" src="https://raw.githubusercontent.com/refinedmods/refinedstorage2/develop/images/logo.png" />
<h1 style="margin-top: 0">Refined Storage 2</h1>
Expand All @@ -15,7 +16,7 @@ access the inventories of many devices through a single unified GUI.

This mod not only adds storage solutions, but also devices that can be used to manipulate items and blocks in the world
and from within the system, such as importers, exporters, constructors, destructors, and more! There are also devices in
this mod that allow the player to setup auto-crafting, allowing the crafting of complex recipes in a few simple clicks.
this mod that allow the player to set up auto-crafting, allowing the crafting of complex recipes in a few simple clicks.

## Links

Expand Down
1 change: 1 addition & 0 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--suppress HttpUrlsUsage -->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java, properties, xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public ComponentMapFactory<C, X> copy() {
return new ComponentMapFactory<>(new LinkedHashMap<>(factories));
}

@SuppressWarnings("unchecked")
public ComponentMap<C> buildComponentMap(final X context) {
final Map<Class<? extends C>, C> components = new LinkedHashMap<>();
factories.forEach((componentType, factory) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void shouldValidateEquals() {
}

@Test
@SuppressWarnings("ObviousNullCheck")
void shouldValidateNull() {
// Act & assert
final Exception e = assertThrows(
Expand All @@ -47,6 +48,7 @@ void shouldValidateNull() {
}

@Test
@SuppressWarnings("ObviousNullCheck")
void shouldValidateNotNull() {
// Act & assert
final Exception e = assertThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public GridQueryParserImpl(final LexerTokenMappings tokenMappings,

@Override
public Predicate<GridResource> parse(final String query) throws GridQueryParserException {
if ("".equals(query.trim())) {
if (query.trim().isEmpty()) {
return resource -> true;
}
final List<Token> tokens = getTokens(query);
Expand Down Expand Up @@ -82,16 +82,13 @@ private Predicate<GridResource> implicitAnd(final List<Node> nodes) throws GridQ
}

private Predicate<GridResource> parseNode(final Node node) throws GridQueryParserException {
if (node instanceof LiteralNode literalNode) {
return parseLiteral(literalNode);
} else if (node instanceof UnaryOpNode unaryOpNode) {
return parseUnaryOp(unaryOpNode);
} else if (node instanceof BinOpNode binOpNode) {
return parseBinOp(binOpNode);
} else if (node instanceof ParenNode parenNode) {
return implicitAnd(parenNode.nodes());
}
throw new GridQueryParserException("Unsupported node", null);
return switch (node) {
case LiteralNode literalNode -> parseLiteral(literalNode);
case UnaryOpNode unaryOpNode -> parseUnaryOp(unaryOpNode);
case BinOpNode binOpNode -> parseBinOp(binOpNode);
case ParenNode parenNode -> implicitAnd(parenNode.nodes());
default -> throw new GridQueryParserException("Unsupported node", null);
};
}

private Predicate<GridResource> parseBinOp(final BinOpNode node) throws GridQueryParserException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public interface GridView {

/**
* Applies a change to a resource. Will update the backing list, and will also update the view list (depending
* if the view is preventing sorting).
* on if the view is preventing sorting).
*
* @param resource the resource
* @param amount the amount, can be negative or positive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void addIntoView(final GridResource resource) {
if (wouldBePosition < 0) {
viewList.add(-wouldBePosition - 1, resource);
} else {
// If the "would be" position is positive, this means that the resource is already contained in the list,
// If the "would-be" position is positive, this means that the resource is already contained in the list,
// comparing with sorting rules.
// This doesn't mean that the *exact* resource is already in the list, but that is purely "contained"
// in the list when comparing with sorting rules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void setUp() {
class InsertTest {
@ParameterizedTest
@EnumSource(GridInsertMode.class)
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldInsertIntoDestination(final GridInsertMode insertMode) {
// Arrange
final Storage source = new LimitedStorageImpl(100);
Expand Down Expand Up @@ -120,6 +121,7 @@ void shouldNotInsertIntoDestinationWhenNoSpaceIsPresentInDestination(final GridI
@Nested
class InsertEntireResourceTest {
@Test
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldInsertIntoDestinationWithRemainder() {
// Arrange
final Storage source = new LimitedStorageImpl(100);
Expand Down Expand Up @@ -192,6 +194,7 @@ public long extract(final ResourceKey resource,
class ExtractTest {
@ParameterizedTest
@EnumSource(GridExtractMode.class)
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldExtractFromSourceToDestination(final GridExtractMode extractMode) {
// Arrange
final Storage destination = new LimitedStorageImpl(100);
Expand Down Expand Up @@ -272,6 +275,7 @@ void shouldNotExtractFromSourceIfThereIsNoSpaceInDestination(final GridExtractMo
@Nested
class ExtractEntireResourceTest {
@Test
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldExtractEntireResourceFromSourceToDestinationIfResourceIsLessThanMaxCount() {
// Arrange
final Storage destination = new LimitedStorageImpl(100);
Expand All @@ -296,6 +300,7 @@ void shouldExtractEntireResourceFromSourceToDestinationIfResourceIsLessThanMaxCo
}

@Test
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldExtractEntireResourceWithRemainderFromSourceToDestinationIfThereIsNotEnoughSpaceInDestination() {
// Arrange
final Storage destination = new LimitedStorageImpl(MAX_COUNT - 1);
Expand Down Expand Up @@ -325,6 +330,7 @@ void shouldExtractEntireResourceWithRemainderFromSourceToDestinationIfThereIsNot
@Nested
class ExtractHalfResourceTest {
@Test
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldExtractSingleAmountIfResourceHasSingleAmountWhenExtractingHalfResourceFromSourceToDestination() {
// Arrange
final Storage destination = new LimitedStorageImpl(MAX_COUNT);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@FieldsAndMethodsAreNonnullByDefault
package com.refinedmods.refinedstorage.api.grid.service;

import com.refinedmods.refinedstorage.api.core.FieldsAndMethodsAreNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ class GridViewImplTest {

@BeforeEach
void setUp() {
viewBuilder = new GridViewBuilderImpl(
resourceAmount -> Optional.of(new GridResourceImpl(resourceAmount)),
viewBuilder = getViewBuilder(resourceAmount -> Optional.of(new GridResourceImpl(resourceAmount)));
}

private static GridViewBuilderImpl getViewBuilder(final GridResourceFactory resourceFactory) {
return new GridViewBuilderImpl(
resourceFactory,
view -> Comparator.comparing(GridResource::getName),
view -> Comparator.comparing(GridResource::getAmount)
);
Expand All @@ -42,10 +46,8 @@ void shouldAddResourcesWithSameNameButDifferentIdentity() {
// in the view, but actually isn't because it has a different identity.

// Arrange
final GridViewBuilder builder = new GridViewBuilderImpl(
resourceAmount -> Optional.of(new GridResourceWithMetadata(resourceAmount)),
view -> Comparator.comparing(GridResource::getName),
view -> Comparator.comparing(GridResource::getAmount)
final GridViewBuilder builder = getViewBuilder(
resourceAmount -> Optional.of(new GridResourceWithMetadata(resourceAmount))
);
final GridView view = builder.build();

Expand Down Expand Up @@ -92,6 +94,7 @@ void shouldPreserveOrderWhenSortingAndTwoResourcesHaveTheSameQuantity() {
}

@Test
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldLoadResourcesAndRetrieveTrackedResourcesProperly() {
// Arrange
final GridView view = viewBuilder
Expand Down Expand Up @@ -344,6 +347,7 @@ void shouldNotReorderExistingResourceWhenPreventingSorting() {
}

@Test
@SuppressWarnings("AssertBetweenInconvertibleTypes") // intellij bug
void shouldUpdateTrackedResourceAfterReceivingChange() {
// Act
final GridView view = viewBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.refinedmods.refinedstorage.api.network.security;

import java.util.Collections;
import java.util.Set;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.5")
public record SecurityPolicy(Set<Permission> allowedPermissions) {
public static final SecurityPolicy EMPTY = new SecurityPolicy(Collections.emptySet());

public static SecurityPolicy of(final Permission... permissions) {
return new SecurityPolicy(Set.of(permissions));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ private void addNetworkNode(final Object testInstance, final Field field) {
final Class<?> type = field.getType();
final Map<String, Object> properties = getProperties(annotation.properties());
final NetworkNode resolvedNode = networkNodeFactories.get(type).create(
annotation,
properties
);
final Network network = networkMap.get(annotation.networkId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.refinedmods.refinedstorage.api.network.impl.node.AbstractNetworkNode;
import com.refinedmods.refinedstorage.api.network.node.NetworkNode;
import com.refinedmods.refinedstorage.network.test.AddNetworkNode;

import java.util.Map;

Expand All @@ -11,8 +10,8 @@ public abstract class AbstractNetworkNodeFactory implements NetworkNodeFactory {
public static final String PROPERTY_ENERGY_USAGE = "energy_usage";

@Override
public final NetworkNode create(final AddNetworkNode ctx, final Map<String, Object> properties) {
final AbstractNetworkNode value = innerCreate(ctx, properties);
public final NetworkNode create(final Map<String, Object> properties) {
final AbstractNetworkNode value = innerCreate(properties);
final boolean active = (boolean) properties.getOrDefault(PROPERTY_ACTIVE, true);
value.setActive(active);
return value;
Expand All @@ -22,5 +21,5 @@ protected final long getEnergyUsage(final Map<String, Object> properties) {
return (long) properties.getOrDefault(PROPERTY_ENERGY_USAGE, 0L);
}

protected abstract AbstractNetworkNode innerCreate(AddNetworkNode ctx, Map<String, Object> properties);
protected abstract AbstractNetworkNode innerCreate(Map<String, Object> properties);
}
Loading

0 comments on commit 13c41ea

Please sign in to comment.