Skip to content

Commit

Permalink
add intellij reformatter on pull requests (#142)
Browse files Browse the repository at this point in the history
use intellij reformatter to fixup formatting in pull requests even if
the change was made without intellij.
this change includes changes to all files that were not formatted
properly before.
  • Loading branch information
breed authored May 15, 2024
1 parent b3a7e44 commit 16eeade
Show file tree
Hide file tree
Showing 60 changed files with 752 additions and 752 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/reformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Re-format Code

on:
pull_request:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Install IntelliJ IDEA
run: |
wget -q -O idea.tar.gz https://download.jetbrains.com/idea/ideaIC-2024.1.1.tar.gz
tar -xzf idea.tar.gz
- name: Format code
run: |
./*/bin/format.sh -m *.java -r .
- name: Commit changes
run: |
git config user.name 'github-actions[bot]'
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -a -m "Auto-format code"
git push
10 changes: 8 additions & 2 deletions .idea/codeStyles/Project.xml

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

25 changes: 13 additions & 12 deletions client/src/main/java/edu/sjsu/moth/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ int listEmails(@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg)
}

private MongoCollection<Document> getEmailRegistrationCollection(Properties props) {
return MongoClients.create("mongodb://%s:27017/".formatted(props.getProperty("db")))
.getDatabase("test")
return MongoClients.create("mongodb://%s:27017/".formatted(props.getProperty("db"))).getDatabase("test")
.getCollection("emailregistration");
}

@Command(description = "delete the record for an email", mixinStandardHelpOptions = true)
int deleteEmail(@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg,
@CommandLine.Parameters(paramLabel = "email") String email, @CommandLine.Option(names = "--no"
+ "-dryrun", defaultValue = "False") boolean noDryrun) {
int deleteEmail(
@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg,
@CommandLine.Parameters(paramLabel = "email") String email,
@CommandLine.Option(names = "--no" + "-dryrun", defaultValue = "False") boolean noDryrun) {
var props = loadProperties(cfg);
var regDb = getEmailRegistrationCollection(props);
var normalizeEmail = normalizeEmail(email);
Expand All @@ -137,11 +137,13 @@ int deleteEmail(@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg,
}

@Command(description = "add or update the mapping of an email", mixinStandardHelpOptions = true)
int updateEmail(@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg,
@CommandLine.Parameters(paramLabel = "email") String email, @CommandLine.Option(names = "-u",
paramLabel = "username", description = "set username") String username,
@CommandLine.Parameters(paramLabel = "password") String password, @CommandLine.Option(names =
"--no-dryrun", defaultValue = "False") boolean noDryrun) {
int updateEmail(
@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg,
@CommandLine.Parameters(paramLabel = "email") String email,
@CommandLine.Option(names = "-u", paramLabel = "username", description = "set username")
String username,
@CommandLine.Parameters(paramLabel = "password") String password,
@CommandLine.Option(names = "--no-dryrun", defaultValue = "False") boolean noDryrun) {
var props = loadProperties(cfg);

var regDb = getEmailRegistrationCollection(props);
Expand All @@ -154,8 +156,7 @@ int updateEmail(@CommandLine.Parameters(paramLabel = "mothConfigFile") File cfg,
updating = true;
System.out.printf("found %s in the database, will update\n", rec.entrySet());
}
var newRec = new Document().append("_id", normalizeEmail(email))
.append("email", email)
var newRec = new Document().append("_id", normalizeEmail(email)).append("email", email)
.append("saltedPassword", encodePassword(password));
if (username != null) {
var prevRec = regDb.find(Filters.eq("username", username)).first();
Expand Down
27 changes: 18 additions & 9 deletions server/src/main/java/edu/sjsu/moth/generated/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ public Actor(String id, String type, String following, String followers, String
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Actor.class.getName())
.append('@')
.append(Integer.toHexString(System.identityHashCode(this)))
sb.append(Actor.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this)))
.append('[');
sb.append(',');
sb.append("id");
Expand Down Expand Up @@ -226,8 +224,8 @@ public String toString() {
public int hashCode() {
int result = 1;
result = ((result * 31) + ((this.featured == null) ? 0 : this.featured.hashCode()));
result = ((result * 31) + ((this.manuallyApprovesFollowers == null) ? 0 :
this.manuallyApprovesFollowers.hashCode()));
result = ((result * 31) +
((this.manuallyApprovesFollowers == null) ? 0 : this.manuallyApprovesFollowers.hashCode()));
result = ((result * 31) + ((this.indexable == null) ? 0 : this.indexable.hashCode()));
result = ((result * 31) + ((this.icon == null) ? 0 : this.icon.hashCode()));
result = ((result * 31) + ((this.publicKey == null) ? 0 : this.publicKey.hashCode()));
Expand Down Expand Up @@ -262,9 +260,20 @@ public boolean equals(Object other) {
return false;
}
Actor rhs = ((Actor) other);
return (((((((((((((((((((((((((Objects.equals(this.featured, rhs.featured)) && (Objects.equals(this.manuallyApprovesFollowers,
rhs.manuallyApprovesFollowers))) && (Objects.equals(this.indexable,
rhs.indexable))) && (Objects.equals(this.icon, rhs.icon))) && (Objects.equals(this.publicKey, rhs.publicKey))) && (Objects.equals(this.type, rhs.type))) && (Objects.equals(this.attachment, rhs.attachment)))) && (Objects.equals(this.id, rhs.id))) && (Objects.equals(this.memorial, rhs.memorial))) && (Objects.equals(this.tag, rhs.tag))) && (Objects.equals(this.summary, rhs.summary))) && (Objects.equals(this.image, rhs.image))) && (Objects.equals(this.endpoints, rhs.endpoints))) && (Objects.equals(this.preferredUsername,
rhs.preferredUsername))) && (Objects.equals(this.devices, rhs.devices))) && (Objects.equals(this.published, rhs.published))) && (Objects.equals(this.outbox, rhs.outbox))) && (Objects.equals(this.featuredTags, rhs.featuredTags))) && (Objects.equals(this.url, rhs.url))) && (Objects.equals(this.followers, rhs.followers))) && (Objects.equals(this.discoverable, rhs.discoverable))) && (Objects.equals(this.following, rhs.following))) && (Objects.equals(this.name, rhs.name))) && (Objects.equals(this.inbox, rhs.inbox)));
return (((((((((((((((((((((((((Objects.equals(this.featured, rhs.featured)) &&
(Objects.equals(this.manuallyApprovesFollowers, rhs.manuallyApprovesFollowers))) &&
(Objects.equals(this.indexable, rhs.indexable))) && (Objects.equals(this.icon, rhs.icon))) &&
(Objects.equals(this.publicKey, rhs.publicKey))) && (Objects.equals(this.type, rhs.type))) &&
(Objects.equals(this.attachment, rhs.attachment)))) && (Objects.equals(this.id, rhs.id))) &&
(Objects.equals(this.memorial, rhs.memorial))) && (Objects.equals(this.tag, rhs.tag))) &&
(Objects.equals(this.summary, rhs.summary))) && (Objects.equals(this.image, rhs.image))) &&
(Objects.equals(this.endpoints, rhs.endpoints))) &&
(Objects.equals(this.preferredUsername, rhs.preferredUsername))) &&
(Objects.equals(this.devices, rhs.devices))) && (Objects.equals(this.published, rhs.published))) &&
(Objects.equals(this.outbox, rhs.outbox))) && (Objects.equals(this.featuredTags, rhs.featuredTags))) &&
(Objects.equals(this.url, rhs.url))) && (Objects.equals(this.followers, rhs.followers))) &&
(Objects.equals(this.discoverable, rhs.discoverable))) &&
(Objects.equals(this.following, rhs.following))) && (Objects.equals(this.name, rhs.name))) &&
(Objects.equals(this.inbox, rhs.inbox)));
}
}
26 changes: 11 additions & 15 deletions server/src/main/java/edu/sjsu/moth/generated/Application.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@

// THIS FILE WAS GENERATED BY JSON2JAVA
// CHANGES MADE:
// * website changed to String type


package edu.sjsu.moth.generated;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"name",
"website"
})
@JsonPropertyOrder({ "name", "website" })
public class Application {

@JsonProperty("name")
Expand All @@ -24,7 +19,6 @@ public class Application {

/**
* No args constructor for use in serialization
*
*/
public Application() {
}
Expand All @@ -38,17 +32,18 @@ public Application(String name, String website) {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Application.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
sb.append(Application.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this)))
.append('[');
sb.append("name");
sb.append('=');
sb.append(((this.name == null)?"<null>":this.name));
sb.append(((this.name == null) ? "<null>" : this.name));
sb.append(',');
sb.append("website");
sb.append('=');
sb.append(((this.website == null)?"<null>":this.website));
sb.append(((this.website == null) ? "<null>" : this.website));
sb.append(',');
if (sb.charAt((sb.length()- 1)) == ',') {
sb.setCharAt((sb.length()- 1), ']');
if (sb.charAt((sb.length() - 1)) == ',') {
sb.setCharAt((sb.length() - 1), ']');
} else {
sb.append(']');
}
Expand All @@ -58,8 +53,8 @@ public String toString() {
@Override
public int hashCode() {
int result = 1;
result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode()));
result = ((result* 31)+((this.website == null)? 0 :this.website.hashCode()));
result = ((result * 31) + ((this.name == null) ? 0 : this.name.hashCode()));
result = ((result * 31) + ((this.website == null) ? 0 : this.website.hashCode()));
return result;
}

Expand All @@ -72,7 +67,8 @@ public boolean equals(Object other) {
return false;
}
Application rhs = ((Application) other);
return (((this.name == rhs.name)||((this.name!= null)&&this.name.equals(rhs.name)))&&((this.website == rhs.website)||((this.website!= null)&&this.website.equals(rhs.website))));
return (((this.name == rhs.name) || ((this.name != null) && this.name.equals(rhs.name))) &&
((this.website == rhs.website) || ((this.website != null) && this.website.equals(rhs.website))));
}

}
7 changes: 3 additions & 4 deletions server/src/main/java/edu/sjsu/moth/generated/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public Attachment(String type, String name, String value) {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Attachment.class.getName())
.append('@')
.append(Integer.toHexString(System.identityHashCode(this)))
sb.append(Attachment.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this)))
.append('[');
sb.append("type");
sb.append('=');
Expand Down Expand Up @@ -80,7 +78,8 @@ public boolean equals(Object other) {
return false;
}
Attachment rhs = ((Attachment) other);
return (((Objects.equals(this.name, rhs.name)) && (Objects.equals(this.type, rhs.type))) && (Objects.equals(this.value, rhs.value)));
return (((Objects.equals(this.name, rhs.name)) && (Objects.equals(this.type, rhs.type))) &&
(Objects.equals(this.value, rhs.value)));
}

}
Loading

0 comments on commit 16eeade

Please sign in to comment.