Skip to content

Commit

Permalink
Merge pull request #271 from usethesource/fix/whitespace
Browse files Browse the repository at this point in the history
Normalize whitespace
  • Loading branch information
jurgenvinju committed Sep 7, 2024
2 parents b4a6545 + decd011 commit cc14797
Show file tree
Hide file tree
Showing 230 changed files with 24,876 additions and 24,762 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80

[*.sh]
end_of_line = lf

[*.java]
indent_size = 4
max_line_length = 120


[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2
13 changes: 13 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Run this command to always ignore formatting commits in `git blame`
# git config blame.ignoreRevsFile .git-blame-ignore-revs

# replaced tabs with spaces
8efd5a7227658bbcc5b46ba647d15edf42dc0302

# removed trailing whitespace
63917fec5f518cd66ebbf56903d5167ac1c815ab

# normalize indentation
4ca06f1346d13d6e275d891de918cc6bae85c3d8
f3301743a5e4ca39b415e4f1fa32c66a39ef37b5

28 changes: 26 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ jobs:
name: Event File
path: ${{ github.event_path }}


lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # run it on the PR, not on the merged commit, for better line numbers

- uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
cache: 'maven'
- name: Run checkstyle and print errors
run: mvn -B checkstyle:checkstyle checkstyle:check
- name: Report build results
uses: gmazzo/publish-report-annotations@v1 # target latest major
if: ${{ !cancelled() }}
with:
testsSummary: off
reports: "target/checkstyle-result.xml"



test:
if: ${{ !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[maven-release-plugin]')) }}
strategy:
Expand All @@ -39,7 +63,7 @@ jobs:
java-version: 11
distribution: 'temurin'
cache: 'maven'

- name: test
run: mvn -B clean test

Expand All @@ -49,7 +73,7 @@ jobs:
with:
name: Unit Test Results (${{ matrix.os }})
path: target/surefire-reports/**/*.xml

checker-framework:
if: ${{ !(github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[maven-release-plugin]')) }}
runs-on: ubuntu-latest
Expand Down
58 changes: 58 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<!-- this checker only defines the things we really do not want, not all the warnings that checkstyle would also allow -->
<module name="SuppressWarningsFilter"/>
<property name="charset" value="UTF-8"/>
<property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, rsc, xml"/>

<!-- allow suppression of errors for certain files -->
<module name="SuppressionFilter">
<property name="file" value="checkstyle-suppressions.xml" />
<property name="optional" value="true"/>
</module>


<!-- Whitespace -->
<module name="FileTabCharacter"> <!-- no tabs -->
<property name="eachLine" value="true"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="[^\s]\s+$"/> <!-- we only care about statements with trailing whitespace, empty lines with some whitespace we're not gointg to be picky about -->

<property name="message" value="Remove trailing whitespace" />
<property name="fileExtensions" value="xml, java, rsc"/>
</module>

<!-- java style things -->
<module name="TreeWalker">
<module name="OuterTypeFilename"/> <!-- make sure the name of the file is the same as the class -->
<module name="AvoidEscapedUnicodeCharacters">
<!-- avoid escapes of unicode chars where we can just write the unicode char in a string -->
<property name="allowEscapesForControlCharacters" value="true"/>
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="NeedBraces"> <!-- make sure that {} are always required, also for single line statements -->
<property name="tokens" value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, LITERAL_WHILE"/>
</module>
<module name="OneStatementPerLine"/>
<module name="FallThrough"/> <!-- can be relieved by explicitly adding a comment that mentions fall[s]?through-->
<module name="ModifierOrder"/>
<module name="NoFinalizer"/>

<module name="Indentation"> <!-- make sure indents happen at a predictable pattern-->
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="4"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="4"/>
</module>

</module>

</module>
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@
</execution>
</executions>
</plugin>
<plugin> <!-- needs to be explictily envoked using mvn checkstyle:check -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/io/usethesource/vallang/IBool.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.usethesource.vallang.visitors.IValueVisitor;

public interface IBool extends IValue {
@Override
@Override
default int getMatchFingerprint() {
if (getValue()) {
return 3569038; /* "true".hashCode() */
Expand All @@ -23,17 +23,17 @@ default int getMatchFingerprint() {
}
}

boolean getValue();
String getStringRepresentation();
IBool and(IBool other);
IBool or(IBool other);
IBool xor(IBool other);
IBool not();
IBool implies(IBool other);
IBool equivalent(IBool other);
@Override
default <T, E extends Throwable> T accept(IValueVisitor<T, E> v) throws E {
return v.visitBoolean(this);
}
boolean getValue();
String getStringRepresentation();
IBool and(IBool other);
IBool or(IBool other);
IBool xor(IBool other);
IBool not();
IBool implies(IBool other);
IBool equivalent(IBool other);

@Override
default <T, E extends Throwable> T accept(IValueVisitor<T, E> v) throws E {
return v.visitBoolean(this);
}
}
22 changes: 11 additions & 11 deletions src/main/java/io/usethesource/vallang/ICollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ public interface ICollection<T extends ICollection<T>> extends IValue, Iterable<
public default Type getElementType() {
return getType().getElementType();
}

/**
* @return true iff this container has no elements
*/
public boolean isEmpty();

/**
* @return an empty collection
*/
public default T empty() {
return writer().done();
}

/**
* @return an empty writer for this collection kind
*/
Expand All @@ -37,20 +37,20 @@ public default T empty() {
* @return the arity of the collection (the number of elements in it)
*/
public int size();

/**
* @return this collection with an IRelation interface
* @throws IllegalOperationException when the container does not contain all tuples of the same arity
*/
public IRelation<T> asRelation();

/**
* @return true iff the collection contains only tuples of a fixed width, if any.
*/
public default boolean isRelation() {
return getElementType().isFixedWidth();
}

/**
* Computes the Cartesian product of two collections
* @param that is another collection
Expand All @@ -62,7 +62,7 @@ public default T product(T that) {
if (that.isEmpty()) {
return that;
}

for (IValue t1 : this) {
for (IValue t2 : that) {
w.appendTuple(t1, t2);
Expand All @@ -71,11 +71,11 @@ public default T product(T that) {

return w.done();
}

/**
* Computes the union of two collections, ignoring duplicates. The original duplicates in the receiver and the given container will dissappear as well.
*
* @param that is the other collection
*
* @param that is the other collection
* @return a collection containing both the elements of the receiver and those of the given container, without introducing duplicates.
*/
public default T union(T that) {
Expand All @@ -84,7 +84,7 @@ public default T union(T that) {
w.appendAll(that);
return w.done();
}

/**
* @return a stream of IValues from the current collection
*/
Expand Down
Loading

0 comments on commit cc14797

Please sign in to comment.