Skip to content
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

Hard-Coded bundle params + few extra strings removed #714 #719

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MattiaPrimavera
Copy link

Done for fragments package bundle parameters + some other hard-coded strings ;)

@maniac103
Copy link
Collaborator

I'd prefer if the string constants had an EXTRA_ prefix to make their usage more obvious.
Also, the filter and sort strings should be moved to the Github API bindings instead.

@@ -26,9 +26,32 @@

import org.eclipse.egit.github.core.Repository;

import java.io.CharArrayReader;
Copy link
Collaborator

Choose a reason for hiding this comment

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

???

Copy link
Author

Choose a reason for hiding this comment

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

typing error (ALT+ENTER) :P

private static final String STATUS_ADDED = "added";
private static final String STATUS_MODIFIED = "modified";
private static final String STATUS_RENAMED = "renamed";
private static final String STATUS_REMOVED = "removed";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move to Github API.

private static final String HEAD_LABEL = "head_label";
private static final String PR = "pr";


Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the second newline.

Copy link
Author

Choose a reason for hiding this comment

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

eagle eyed :P

@@ -91,7 +94,7 @@ public static SearchFragment newInstance(int initialType, String initialQuery) {
private static final String SUGGESTION_ORDER = SuggestionsProvider.Columns.DATE + " DESC";

private static final String STATE_KEY_QUERY = "query";
private static final String STATE_KEY_SEARCH_TYPE = "search_type";
private static final String STATE_KEY_SEARCH_TYPE = SEARCH_TYPE;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Extra key and state key are unrelated, please restore the string literal to not give the impression they are related.

private static final String LOGIN = "login";
private static final String SORT = "sort";
private static final String PUSHED = "pushed";
private static final String AFFILIATINO = "affiliation";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo.

Also, the filter strings should live in the Github API bindings.

Copy link
Author

Choose a reason for hiding this comment

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

you meant "AFFILIATINO" spelling error right ?

Copy link
Author

Choose a reason for hiding this comment

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

the filter strings should live in the Github API bindings.

I created a Constants file

Copy link
Collaborator

@maniac103 maniac103 Sep 11, 2017

Choose a reason for hiding this comment

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

you meant "AFFILIATINO" spelling error right ?

Yes.

I created a Constants file

Plesse change that to either use the existing IGithubConstants class or put the constants to the respective service classes. If the constants only apply to one service, I'd prefer the latter.

@MattiaPrimavera
Copy link
Author

Argh I though about the prefix, was not sure on your conventions ...

@@ -83,6 +83,7 @@

protected String mLogin;
private EventAdapter mAdapter;
private static final String LOGIN = "login";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd say to move it up to the rest of statics.

@Tunous
Copy link
Collaborator

Tunous commented Sep 11, 2017

Not sure if we follow this rule elsewhere but I think it's a good idea to keep static fields above instance fields. I saw that you placed them together in some files.

@maniac103
Copy link
Collaborator

Not sure if we follow this rule elsewhere but I think it's a good idea to keep static fields above instance fields.

👍 If we don't do it in all places yet, we definitely should do that.

Tunous
Tunous previously requested changes Sep 11, 2017
Copy link
Collaborator

@Tunous Tunous left a comment

Choose a reason for hiding this comment

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

Nearly there. Remaining questions should be answered by @maniac103.

@@ -191,19 +198,19 @@ protected void fillStats(List<CommitFile> files, List<CommitComment> comments) {
final LinearLayout parent;

switch (file.getStatus()) {
case "added":
case Constants.STATUS_ADDED:
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should go to CommitFile.java instead.

return new CommitStatusLoader(getActivity(), mRepoOwner, mRepoName,
mPullRequest.getHead().getSha());
}
@Override
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert. This was indented like this on purpose.

private static final String STATE_KEY_QUERY = "search_query";
private static final String STATE_KEY_SEARCH_IS_EXPANDED = "search_is_expanded";
private static final String FILTER_ALL = "all";
private static final String OWNER = "owner";
Copy link
Collaborator

Choose a reason for hiding this comment

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

These will probably need some prefix or be moved to another file.
@maniac103

Copy link
Author

Choose a reason for hiding this comment

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

FilterConstants file is good ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have found that RepositoryService already contains some of these so the rest should be moved here too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the naming. Filter constants should start with TYPE_ as these already present in RepositoryService. Sort constants should be prefixed with SORT_. And the main, search tag are specific to this fragment so these 2 leave here.

@@ -56,7 +57,7 @@ public static UserFragment newInstance(String login) {
UserFragment f = new UserFragment();

Bundle args = new Bundle();
args.putString("login", login);
args.putString(Constants.EXTRA_LOGIN, login);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep extra in this file.

@@ -85,8 +86,8 @@ protected void onResultReady(User result) {
@Override
protected Loader<LoaderResult<Collection<Repository>>> onCreateLoader() {
Map<String, String> filterData = new HashMap<>();
filterData.put("sort", "pushed");
filterData.put("affiliation", "owner,collaborator");
filterData.put(Constants.EXTRA_SORT, Constants.PUSHED);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably move to Repository.java?

Copy link
Author

Choose a reason for hiding this comment

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

I moved it to IGithubConstants

@@ -0,0 +1,12 @@
package org.eclipse.egit.github.core.util;

public class Constants {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file shouldn't be needed.

import static org.eclipse.egit.github.core.CommitFile.STATUS_ADDED;
import static org.eclipse.egit.github.core.CommitFile.STATUS_MODIFIED;
import static org.eclipse.egit.github.core.CommitFile.STATUS_REMOVED;
import static org.eclipse.egit.github.core.CommitFile.STATUS_RENAMED;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please avoid static imports and use CommitFile.STATUS_* below instead.

public static CommitFragment newInstance(String repoOwner, String repoName, String commitSha,
RepositoryCommit commit, List<CommitComment> comments) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove that newline.

Event.TYPE_PUSH, Event.TYPE_ISSUES, Event.TYPE_WATCH, Event.TYPE_CREATE,
Event.TYPE_PULL_REQUEST, Event.TYPE_COMMIT_COMMENT, Event.TYPE_DELETE,
Event.TYPE_DOWNLOAD, Event.TYPE_FORK_APPLY, Event.TYPE_PUBLIC,
Event.TYPE_MEMBER, Event.TYPE_ISSUE_COMMENT
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is unrelated, please remove.

private RootAdapter<T, ? extends RecyclerView.ViewHolder> mAdapter;
private PageIteratorWithSaveableState<T> mIterator;
private boolean mIsLoadCompleted;
private View mLoadingView;

private static final String STATE_KEY_ITERATOR_STATE = "iterator_state";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated change, please remove.


private void fillStatus(List<CommitStatus> statuses) {
private void fillStatus(List<CommitStatus> statuses) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whitespace errors.

public class UserFragment extends LoadingFragmentBase implements View.OnClickListener {
public static final String EXTRA_LOGIN = "login";
Copy link
Collaborator

Choose a reason for hiding this comment

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

public -> private

import org.xml.sax.SAXException;

Copy link
Collaborator

Choose a reason for hiding this comment

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

No unrelated whitespace changes please.

filterData.put("sort", "pushed");
filterData.put("affiliation", "owner,collaborator");
filterData.put(EXTRA_SORT, PUSHED);
filterData.put(EXTRA_AFFILIATION, "owner,collaborator");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Those aren't extras, but filter fields. Please move those to RepositoryService (see IssueService for example on variable naming).


String EXTRA_SORT = "sort";
String EXTRA_AFFILIATION = "affiliation";
String PUSHED = "pushed";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove as per above.

public static final String STARRED = "starred";
public static final String FULL_NAME = "full_name";
public static final String MAIN_TAG = "main";
public static final String SEARCH_TAG = "search";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fragment tags don't belong into the Github API, but to their respective activity.

All other items are filter fields (right?) and thus should be moved to the respective service (RepositoryService, I guess) with appropriate naming.

@Tunous Tunous force-pushed the fixing_hard_coded_params branch 2 times, most recently from d9247f1 to 397eea9 Compare March 24, 2018 16:29
@Tunous
Copy link
Collaborator

Tunous commented Mar 24, 2018

I've rebased this onto master, fixed mentioned issues and added similar constants to activity files.

@Tunous Tunous dismissed their stale review March 24, 2018 16:52

Pushed my own changes

@Tunous Tunous requested a review from maniac103 March 24, 2018 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants