Skip to content

Add and enforce checkstyle, lint, findbugs, and pmd #420

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

Merged
merged 50 commits into from
Dec 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6e88dda
Add quality checks
SUPERCILEX Nov 19, 2016
c0078f8
Make Travis compile all code
SUPERCILEX Nov 24, 2016
74ffc44
Check everything
SUPERCILEX Nov 24, 2016
90b09c1
Add fake google-services.json
SUPERCILEX Nov 24, 2016
7839d13
Fix Travis
SUPERCILEX Nov 24, 2016
96aaf1f
Fix Travis
SUPERCILEX Nov 24, 2016
0ee8f0d
Add lint reports
SUPERCILEX Nov 24, 2016
75cc581
Work on lint
SUPERCILEX Nov 24, 2016
b5bcee2
Merge remote-tracking branch 'firebase/master' into checkstyle_pmd_fi…
SUPERCILEX Nov 24, 2016
d032a38
Merge branch 'travis' into checkstyle_pmd_findbugs
SUPERCILEX Nov 24, 2016
0666dba
Fix all issues caught by findbugs, checkstyle, lint, and pmd
SUPERCILEX Nov 24, 2016
b14a741
Fix Travis
SUPERCILEX Nov 24, 2016
3ddc05b
Fix Travis
SUPERCILEX Nov 24, 2016
871c145
Fix Travis
SUPERCILEX Nov 24, 2016
580bec7
Fix Travis
SUPERCILEX Nov 24, 2016
9acf6df
Fix Travis
SUPERCILEX Nov 24, 2016
afbf417
Fix Travis
SUPERCILEX Nov 24, 2016
6e21b73
Fix Travis
SUPERCILEX Nov 24, 2016
5209a54
Update .travis.yml
SUPERCILEX Nov 24, 2016
991c370
Update .travis.yml
SUPERCILEX Nov 24, 2016
dc9a80c
Update .travis.yml
SUPERCILEX Nov 24, 2016
9868fc4
Update .travis.yml
SUPERCILEX Nov 24, 2016
2e5ca81
Fix Travis
SUPERCILEX Nov 24, 2016
8e261e5
Fix Travis
SUPERCILEX Nov 24, 2016
8169e28
Fix Travis
SUPERCILEX Nov 24, 2016
84090d5
Fix Travis
SUPERCILEX Nov 24, 2016
5e946a9
Fix Travis
SUPERCILEX Nov 24, 2016
fb0dd31
Fix Travis
SUPERCILEX Nov 24, 2016
aab0760
Fix Travis
SUPERCILEX Nov 24, 2016
4e478d4
Fix Travis
SUPERCILEX Nov 25, 2016
11fefe4
Cleanup
SUPERCILEX Nov 25, 2016
b37e4fd
Merge remote-tracking branch 'firebase/master' into checkstyle_pmd_fi…
SUPERCILEX Nov 28, 2016
b9129b6
Fix Travis
SUPERCILEX Nov 28, 2016
adaef2a
Fix Travis
SUPERCILEX Nov 28, 2016
6ea98f1
Fix Travis
SUPERCILEX Nov 28, 2016
2b06133
Fix Travis
SUPERCILEX Nov 28, 2016
6bf27aa
Merge remote-tracking branch 'firebase/master' into checkstyle_pmd_fi…
SUPERCILEX Nov 28, 2016
3f201bc
Make gradle check depend on prepareArtifacts to make sure the lib is …
SUPERCILEX Nov 28, 2016
2ba7761
Merge remote-tracking branch 'firebase/master' into checkstyle_pmd_fi…
SUPERCILEX Dec 2, 2016
2269cdf
Fix merge mistakes
SUPERCILEX Dec 2, 2016
861232d
Update README.md
SUPERCILEX Dec 2, 2016
075e6b2
Update Facebook SDK to fix Travis
SUPERCILEX Dec 2, 2016
6100fa2
Fix typo
SUPERCILEX Dec 2, 2016
a5a61a0
Disable NewerVersionAvailable lint check
SUPERCILEX Dec 2, 2016
a8d4e49
Merge remote-tracking branch 'firebase/master' into checkstyle_pmd_fi…
SUPERCILEX Dec 2, 2016
ee69abc
Merge remote-tracking branch 'firebase/master' into checkstyle_pmd_fi…
SUPERCILEX Dec 6, 2016
a76efd6
Merge remote-tracking branch 'firebase/version-1.1.0-dev' into checks…
SUPERCILEX Dec 6, 2016
465534c
Fix merge mistakes
SUPERCILEX Dec 6, 2016
2b05ffe
Remove unused string resource
SUPERCILEX Dec 6, 2016
c2d6f37
Cleanup
SUPERCILEX Dec 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.gradle
/**/*.iml
/local.properties
.idea
.DS_Store
/build
/captures
/library/target
/**/*.iml
google-services.json
build/
43 changes: 38 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,45 @@ cache:
- $HOME/.gradle/wrapper/
android:
components:
- platform-tools
- tools
- build-tools-25.0.1
- android-25

# Extras
- extra-google-m2repository
- platform-tools
- extra-android-m2repository
script: ./gradlew clean :library:testAll :library:prepareArtifacts
- extra-google-m2repository
before_script: mv library/google-services.json app/google-services.json
script: ./gradlew clean assembleDebug check
after_failure:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What was prepareArtifacts for?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's the command I run before uploading to jCenter, I want to run it on each build to make sure that the build will be "releasable".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good, I added it as a dependency of gradle's check.

# tests
- cat app/build/reports/tests/testDebugUnitTest/index.html
- cat auth/build/reports/tests/testDebugUnitTest/index.html
- cat database/build/reports/tests/testDebugUnitTest/index.html
- cat storage/build/reports/tests/testDebugUnitTest/index.html

# app
- cat app/build/reports/checkstyle.html
- cat app/build/reports/lint-results.xml
- cat app/build/reports/lint-results.html
- cat app/build/reports/findbugs.html
- cat app/build/reports/pmd.html

# auth
- cat auth/build/reports/checkstyle.html
- cat auth/build/reports/lint-results.xml
- cat auth/build/reports/lint-results.html
- cat auth/build/reports/findbugs.html
- cat auth/build/reports/pmd.html

# database
- cat database/build/reports/checkstyle.html
- cat database/build/reports/lint-results.xml
- cat database/build/reports/lint-results.html
- cat database/build/reports/findbugs.html
- cat database/build/reports/pmd.html

# storage
- cat storage/build/reports/checkstyle.html
- cat storage/build/reports/lint-results.xml
- cat storage/build/reports/lint-results.html
- cat storage/build/reports/findbugs.html
- cat storage/build/reports/pmd.html
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply from: "../common/constants.gradle"
apply from: "../constants.gradle"
apply from: '../library/quality/quality.gradle'

android {
compileSdkVersion compileSdk
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
<application
android:name=".auth.LeakCatcher"
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity android:name=".ChooserActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
9 changes: 4 additions & 5 deletions app/src/main/java/com/firebase/uidemo/ChooserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,21 @@ public void onItemClick(int position) {
public static class MyArrayAdapter extends ArrayAdapter<Class> {

private Context mContext;
private Class[] mClasses;

public MyArrayAdapter(Context context, int resource, Class[] objects) {
public MyArrayAdapter(Context context, int resource, Class... objects) {
super(context, resource, objects);

mContext = context;
mClasses = objects;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
View view;

if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(android.R.layout.simple_list_item_2, null);
} else {
view = convertView;
}

((TextView) view.findViewById(android.R.id.text1)).setText(DESCRIPTION_NAMES[position]);
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import com.bumptech.glide.Glide;
import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.IdpResponse;
Expand All @@ -42,8 +40,13 @@
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;

import java.util.Iterator;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SignedInActivity extends AppCompatActivity {
private static final String EXTRA_IDP_RESPONSE = "extra_idp_response";

Expand Down Expand Up @@ -144,7 +147,7 @@ private void populateProfile() {
mUserDisplayName.setText(
TextUtils.isEmpty(user.getDisplayName()) ? "No display name" : user.getDisplayName());

StringBuilder providerList = new StringBuilder();
StringBuilder providerList = new StringBuilder(100);

providerList.append("Providers used: ");

Expand Down
47 changes: 28 additions & 19 deletions app/src/main/java/com/firebase/uidemo/database/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@
import com.google.firebase.database.Query;

public class ChatActivity extends AppCompatActivity implements FirebaseAuth.AuthStateListener {

public static final String TAG = "RecyclerViewDemo";
private static final String TAG = "RecyclerViewDemo";

private FirebaseAuth mAuth;
private DatabaseReference mRef;
private DatabaseReference mChatRef;
private Button mSendButton;
private EditText mMessageEdit;
Expand All @@ -71,8 +69,7 @@ protected void onCreate(Bundle savedInstanceState) {
mSendButton = (Button) findViewById(R.id.sendButton);
mMessageEdit = (EditText) findViewById(R.id.messageEdit);

mRef = FirebaseDatabase.getInstance().getReference();
mChatRef = mRef.child("chats");
mChatRef = FirebaseDatabase.getInstance().getReference().child("chats");

mSendButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -146,7 +143,7 @@ private void attachRecyclerViewAdapter() {
@Override
public void populateViewHolder(ChatHolder chatView, Chat chat, int position) {
chatView.setName(chat.getName());
chatView.setText(chat.getText());
chatView.setText(chat.getMessage());

FirebaseUser currentUser = mAuth.getCurrentUser();
if (currentUser != null && chat.getUid().equals(currentUser.getUid())) {
Expand Down Expand Up @@ -188,7 +185,7 @@ public void onComplete(@NonNull Task<AuthResult> task) {
}

public boolean isSignedIn() {
return (mAuth.getCurrentUser() != null);
return mAuth.getCurrentUser() != null;
}

public void updateUI() {
Expand All @@ -198,30 +195,42 @@ public void updateUI() {
}

public static class Chat {

String name;
String text;
String uid;
private String mName;
private String mMessage;
private String mUid;

public Chat() {
// Needed for Firebase
}

public Chat(String name, String uid, String message) {
this.name = name;
this.text = message;
this.uid = uid;
public Chat(String name, String message, String uid) {
mName = name;
mMessage = message;
mUid = uid;
}

public String getName() {
return name;
return mName;
}

public void setName(String name) {
mName = name;
}

public String getMessage() {
return mMessage;
}

public void setMessage(String message) {
mMessage = message;
}

public String getUid() {
return uid;
return mUid;
}

public String getText() {
return text;
public void setUid(String uid) {
mUid = uid;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/chat_message_arrow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<stroke
android:color="@android:color/transparent"
android:width="10dp"/>
<solid android:color="@color/material_grey_300"/>
<solid android:color="@color/material_gray_300"/>
</shape>
</rotate>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/chat_message_background.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp"/>
<solid android:color="@color/material_grey_300"/>
<solid android:color="@color/material_gray_300"/>
</shape>
9 changes: 5 additions & 4 deletions app/src/main/res/layout/activity_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,24 @@
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingLeft="16dp">
android:paddingLeft="16dp"
android:paddingStart="16dp">

<EditText
android:id="@+id/messageEdit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
android:layout_weight="1"
android:inputType="text"/>

<Button
android:id="@+id/sendButton"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:text="Send"/>
android:text="@string/send"/>

</LinearLayout>

Expand Down
9 changes: 5 additions & 4 deletions app/src/main/res/layout/activity_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upload"/>
android:text="@string/upload"/>

<Button
android:id="@+id/button_choose_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose Image"/>
android:text="@string/choose_image"/>

<TextView
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Download"/>
android:text="@string/download"/>

<LinearLayout
android:layout_width="wrap_content"
Expand All @@ -40,14 +40,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Download"/>
android:text="@string/download"/>

</LinearLayout>

<ImageView
android:id="@+id/first_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/accessibility_downloaded_image"
android:scaleType="centerCrop"
android:src="#E6E6E6"
android:visibility="invisible"
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/auth_ui_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="16dp"
android:paddingBottom="32dp"
android:orientation="vertical">
android:orientation="vertical"
android:paddingBottom="32dp">

<TextView
style="@style/Base.TextAppearance.AppCompat.Headline"
Expand Down Expand Up @@ -167,8 +167,8 @@
</RadioGroup>

<TextView
style="@style/Base.TextAppearance.AppCompat.Subhead"
android:id="@+id/facebook_scopes_label"
style="@style/Base.TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
Expand All @@ -190,8 +190,8 @@
android:text="@string/photos"/>

<TextView
style="@style/Base.TextAppearance.AppCompat.Subhead"
android:id="@+id/google_scopes_label"
style="@style/Base.TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
Expand All @@ -210,7 +210,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="Drive File"/>
android:text="@string/drive_file"/>

<TextView
style="@style/Base.TextAppearance.AppCompat.Subhead"
Expand Down
Loading