-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Implementation of the public discord statuspage api #55
base: master
Are you sure you want to change the base?
Conversation
to deny access to internal methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR needs work.
I saw no documentation, very inconsistent code-style, improper and overuse of the javax.annotation
API, and other things that preclude it from being merged.
@Nonnull | ||
protected static final String URL_SCHEDULED_MAINTENANCES_ACTIVE = URL_API_BASE + "scheduled-maintenances/active.json"; | ||
@Nonnull | ||
protected static final String URL_SCHEDULED_MAINTENANCES_UPCOMING = URL_API_BASE + "scheduled-maintenances/upcoming.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the scheduled-maintenances
endpoints and organization's sake, we should have a base url
@Nonnull
protected static final String URL_SCHEDULED_MAINTENANCES_BASE = URL_API_BASE + "scheduled-maintenances";
@Nonnull
protected static final String URL_SCHEDULED_MAINTENANCES_ALL = URL_SCHEDULED_MAINTENANCES_BASE + ".json";
@Nonnull
protected static final String URL_SCHEDULED_MAINTENANCES_ACTIVE = URL_SCHEDULED_MAINTENANCES_BASE + "/active.json";
@Nonnull
protected static final String URL_SCHEDULED_MAINTENANCES_UPCOMING = URL_SCHEDULED_MAINTENANCES_BASE + "/upcoming.json";
The same might be worth doing for incidents
although I'll leave that up to you.
@Nonnull | ||
final JSONObject statusObject = object.getJSONObject("status"); | ||
@Nonnull | ||
final Status status = createStatus(statusObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a reason to have @Nonnull
, @Nullable
, and similar kinds of annotations in method bodies.
I won't make you remove any of the method, class, and field annotations, but I would be hesitant on adding nullable annotations in the future as I have been considering adding them to the library myself, but only if and when feature/nullability
is merged.
@Nonnull | ||
final Page page = createPage(pageObject); | ||
|
||
return new Incidents(page, incidents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment on @Nonnull
and @Nullable
in method bodies
@Nonnull | ||
final List<ScheduledMaintenance> scheduledMaintenances = new ArrayList<>(scheduledMaintenancesArray.length()); | ||
for (int i = 0; i < scheduledMaintenancesArray.length(); i++) | ||
scheduledMaintenances.add(createScheduledMaintenance(scheduledMaintenancesArray.getJSONObject(i))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment on @Nonnull
and @Nullable
in method bodies
@Nonnull | ||
final JSONObject statusObject = object.getJSONObject("status"); | ||
@Nonnull | ||
final Status status = createStatus(statusObject); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment on @Nonnull
and @Nullable
in method bodies
|
||
@Override | ||
@Nonnull | ||
public List<Incident> subList(int fromIndex, int toIndex) {return incidents.subList(fromIndex, toIndex);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting seems fairly... odd?
|
||
@Override | ||
@Nonnull | ||
public List<ScheduledMaintenance> subList(int fromIndex, int toIndex) {return ScheduledMaintenances.subList(fromIndex, toIndex);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting seems fairly... odd?
@Nonnull | ||
protected final Page page; | ||
@Nonnull | ||
protected final List<ScheduledMaintenance> ScheduledMaintenances; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this formatting...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a json2pojo generator, probably just didn't saw what it has done here.
public <T> T[] toArray(@Nonnull T[] a) {return ScheduledMaintenances.toArray(a);} | ||
|
||
@Override | ||
public boolean add(ScheduledMaintenance ScheduledMaintenance) {return ScheduledMaintenances.add(ScheduledMaintenance);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is marked as @Immutable
yet we are allowing modification of the underlying list?
This should throw UnsupportedOperationException
or the List
interface should not be implemented at all.
(This goes for all other methods that might modify this object)
{ | ||
statuspage.getSummary().get(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this test class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is wrong with tests?
This would also be a good time to mention that changes to our build setup should be made to allow certain modules to not be included in the collective dependency (IE: |
and implemented this for the statuspage module.
…m/JDA-Applications/JDA-Utilities into feature/statuspage # Conflicts: # build.gradle
…m/JDA-Applications/JDA-Utilities into feature/statuspage # Conflicts: # build.gradle # command/build.gradle # doc/build.gradle # examples/build.gradle # menu/build.gradle # settings.gradle
which can be found here. This currently does not include the uptime tracker or incident history (more than last 50 incidents) as they are not part of the public api. Probably also still needs a bit more documentation.