Merge pull request #103 from nextcloud/codacy

Improving codacy score
This commit is contained in:
Mario Đanić 2018-02-23 20:57:48 +01:00 committed by GitHub
commit 8acb9e705f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 38 additions and 65 deletions

View File

@ -33,7 +33,6 @@ import autodagger.AutoInjector;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class MagicFirebaseInstanceIDService extends FirebaseInstanceIdService { public class MagicFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MagicFirebaseInstanceIDService";
@Inject @Inject
AppPreferences appPreferences; AppPreferences appPreferences;

View File

@ -30,7 +30,6 @@ import com.nextcloud.talk.jobs.NotificationJob;
import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.bundle.BundleKeys;
public class MagicFirebaseMessagingService extends FirebaseMessagingService { public class MagicFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MagicFirebaseMessagingService";
@SuppressLint("LongLogTag") @SuppressLint("LongLogTag")
@Override @Override

View File

@ -30,7 +30,7 @@ import com.nextcloud.talk.interfaces.ClosedInterface;
public class ClosedInterfaceImpl implements ClosedInterface, ProviderInstallListener { public class ClosedInterfaceImpl implements ClosedInterface, ProviderInstallListener {
@Override @Override
public void ProviderInstallerInstallIfNeededAsync() { public void providerInstallerInstallIfNeededAsync() {
ProviderInstaller.installIfNeededAsync(NextcloudTalkApplication.getSharedApplication().getApplicationContext(), ProviderInstaller.installIfNeededAsync(NextcloudTalkApplication.getSharedApplication().getApplicationContext(),
this); this);
} }

View File

@ -761,7 +761,7 @@ public class CallActivity extends AppCompatActivity {
} }
private void joinRoomAndCall() { private void joinRoomAndCall() {
if (callSession.equals("0")) { if ("0".equals(callSession)) {
ncApi.joinRoom(credentials, ApiUtils.getUrlForRoomParticipants(baseUrl, roomToken), null) ncApi.joinRoom(credentials, ApiUtils.getUrlForRoomParticipants(baseUrl, roomToken), null)
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())

View File

@ -36,7 +36,6 @@ import eu.davidea.viewholders.FlexibleViewHolder;
public class NewCallHeaderItem extends AbstractHeaderItem<NewCallHeaderItem.HeaderViewHolder> public class NewCallHeaderItem extends AbstractHeaderItem<NewCallHeaderItem.HeaderViewHolder>
implements IHeader<NewCallHeaderItem.HeaderViewHolder> { implements IHeader<NewCallHeaderItem.HeaderViewHolder> {
private static final String TAG = "NewCallHeaderItem";
HeaderViewHolder headerViewHolder; HeaderViewHolder headerViewHolder;

View File

@ -131,7 +131,7 @@ public class NextcloudTalkApplication extends MultiDexApplication {
componentApplication.inject(this); componentApplication.inject(this);
refWatcher = LeakCanary.install(this); refWatcher = LeakCanary.install(this);
new ClosedInterfaceImpl().ProviderInstallerInstallIfNeededAsync(); new ClosedInterfaceImpl().providerInstallerInstallIfNeededAsync();
DeviceUtils.ignoreSpecialBatteryFeatures(); DeviceUtils.ignoreSpecialBatteryFeatures();
new JobRequest.Builder(PushRegistrationJob.TAG).setUpdateCurrent(true).startNow().build().schedule(); new JobRequest.Builder(PushRegistrationJob.TAG).setUpdateCurrent(true).startNow().build().schedule();

View File

@ -113,8 +113,6 @@ public class CallsListController extends BaseController implements SearchView.On
@BindView(R.id.fast_scroller) @BindView(R.id.fast_scroller)
FastScroller fastScroller; FastScroller fastScroller;
private SmoothScrollLinearLayoutManager layoutManager;
private UserEntity userEntity; private UserEntity userEntity;
private Disposable roomsQueryDisposable; private Disposable roomsQueryDisposable;
private FlexibleAdapter<CallItem> adapter; private FlexibleAdapter<CallItem> adapter;
@ -122,7 +120,6 @@ public class CallsListController extends BaseController implements SearchView.On
private BottomSheet bottomSheet; private BottomSheet bottomSheet;
private MenuItem searchItem; private MenuItem searchItem;
private Menu menuVariable;
private SearchView searchView; private SearchView searchView;
private String searchQuery; private String searchQuery;
@ -149,13 +146,12 @@ public class CallsListController extends BaseController implements SearchView.On
userEntity = userUtils.getCurrentUser(); userEntity = userUtils.getCurrentUser();
if (userEntity == null) { if (userEntity == null &&
if (getParentController() != null && getParentController().getRouter() != null) { getParentController() != null && getParentController().getRouter() != null) {
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController()) getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
.pushChangeHandler(new HorizontalChangeHandler()) .pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()))); .popChangeHandler(new HorizontalChangeHandler())));
} }
}
if (adapter == null) { if (adapter == null) {
adapter = new FlexibleAdapter<>(callItems, getActivity(), false); adapter = new FlexibleAdapter<>(callItems, getActivity(), false);
@ -247,7 +243,6 @@ public class CallsListController extends BaseController implements SearchView.On
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_conversation_plus_filter, menu); inflater.inflate(R.menu.menu_conversation_plus_filter, menu);
menuVariable = menu;
searchItem = menu.findItem(R.id.action_search); searchItem = menu.findItem(R.id.action_search);
initSearchView(); initSearchView();
} }
@ -334,7 +329,8 @@ public class CallsListController extends BaseController implements SearchView.On
} }
private void prepareViews() { private void prepareViews() {
layoutManager = new SmoothScrollLinearLayoutManager(getActivity()); SmoothScrollLinearLayoutManager layoutManager =
new SmoothScrollLinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
@ -362,12 +358,11 @@ public class CallsListController extends BaseController implements SearchView.On
private void dispose(@Nullable Disposable disposable) { private void dispose(@Nullable Disposable disposable) {
if (disposable != null && !disposable.isDisposed()) { if (disposable != null && !disposable.isDisposed()) {
disposable.dispose(); disposable.dispose();
} else if (disposable == null) { } else if (disposable == null &&
roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed() {
if (roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed()) {
roomsQueryDisposable.dispose(); roomsQueryDisposable.dispose();
roomsQueryDisposable = null; roomsQueryDisposable = null;
}
} }
} }

View File

@ -184,20 +184,18 @@ public class ContactsController extends BaseController implements SearchView.OnQ
userEntity = userUtils.getCurrentUser(); userEntity = userUtils.getCurrentUser();
if (userEntity == null) { if (userEntity == null &&
if (getParentController().getRouter() != null) { getParentController() != null && getParentController().getRouter() != null) {
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController()) getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
.pushChangeHandler(new HorizontalChangeHandler()) .pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()))); .popChangeHandler(new HorizontalChangeHandler())));
} }
}
if (adapter == null) { if (adapter == null) {
adapter = new FlexibleAdapter<>(contactItems, getActivity(), false); adapter = new FlexibleAdapter<>(contactItems, getActivity(), false);
adapter.setNotifyChangeOfUnfilteredItems(true) adapter.setNotifyChangeOfUnfilteredItems(true)
.setMode(SelectableAdapter.Mode.MULTI); .setMode(SelectableAdapter.Mode.MULTI);
if (userEntity != null) { if (userEntity != null) {
fetchData(); fetchData();
} }

View File

@ -65,7 +65,6 @@ import io.reactivex.disposables.Disposable;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class SwitchAccountController extends BaseController { public class SwitchAccountController extends BaseController {
private static final String TAG = "SwitchAccountController";
@Inject @Inject
UserUtils userUtils; UserUtils userUtils;

View File

@ -41,7 +41,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.controllers.ContactsController; import com.nextcloud.talk.controllers.ContactsController;
import com.nextcloud.talk.controllers.base.BaseController; import com.nextcloud.talk.controllers.base.BaseController;
import com.nextcloud.talk.events.BottomSheetLockEvent; import com.nextcloud.talk.events.BottomSheetLockEvent;
import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.models.json.rooms.Room; import com.nextcloud.talk.models.json.rooms.Room;
import com.nextcloud.talk.utils.ShareUtils; import com.nextcloud.talk.utils.ShareUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys; import com.nextcloud.talk.utils.bundle.BundleKeys;
@ -79,8 +78,6 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
private MenuType menuType; private MenuType menuType;
private Intent shareIntent; private Intent shareIntent;
private UserEntity currentUser;
public CallMenuController(Bundle args) { public CallMenuController(Bundle args) {
super(args); super(args);
this.room = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM)); this.room = Parcels.unwrap(args.getParcelable(BundleKeys.KEY_ROOM));
@ -98,8 +95,6 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
protected void onViewBound(@NonNull View view) { protected void onViewBound(@NonNull View view) {
super.onViewBound(view); super.onViewBound(view);
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
currentUser = userUtils.getCurrentUser();
prepareViews(); prepareViews();
} }

View File

@ -59,7 +59,6 @@ import studio.carbonylgroup.textfieldboxes.TextFieldBoxes;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class EntryMenuController extends BaseController { public class EntryMenuController extends BaseController {
private static final String TAG = "EntryMenuController";
@BindView(R.id.ok_button) @BindView(R.id.ok_button)
Button proceedButton; Button proceedButton;

View File

@ -68,7 +68,6 @@ import retrofit2.HttpException;
@AutoInjector(NextcloudTalkApplication.class) @AutoInjector(NextcloudTalkApplication.class)
public class OperationsMenuController extends BaseController { public class OperationsMenuController extends BaseController {
private static final String TAG = "OperationsMenuController";
@BindView(R.id.progress_bar) @BindView(R.id.progress_bar)
ProgressBar progressBar; ProgressBar progressBar;

View File

@ -21,5 +21,5 @@
package com.nextcloud.talk.interfaces; package com.nextcloud.talk.interfaces;
public interface ClosedInterface { public interface ClosedInterface {
void ProviderInstallerInstallIfNeededAsync(); void providerInstallerInstallIfNeededAsync();
} }

View File

@ -31,7 +31,6 @@ import com.nextcloud.talk.jobs.NotificationJob;
import com.nextcloud.talk.jobs.PushRegistrationJob; import com.nextcloud.talk.jobs.PushRegistrationJob;
public class MagicJobCreator implements JobCreator { public class MagicJobCreator implements JobCreator {
private static final String TAG = "MagicJobCreator";
@Nullable @Nullable
@Override @Override

View File

@ -32,7 +32,6 @@ import android.os.Build;
public class NotificationUtils { public class NotificationUtils {
public static final String NOTIFICATION_CHANNEL_CALLS = "NOTIFICATION_CHANNEL_CALLS"; public static final String NOTIFICATION_CHANNEL_CALLS = "NOTIFICATION_CHANNEL_CALLS";
public static final String NOTIFICATION_CHANNEL_MESSAGES = "NOTIFICATION_CHANNEL_MESSAGES"; public static final String NOTIFICATION_CHANNEL_MESSAGES = "NOTIFICATION_CHANNEL_MESSAGES";
private static final String TAG = "NotificationUtils";
@TargetApi(Build.VERSION_CODES.O) @TargetApi(Build.VERSION_CODES.O)
public static void createNotificationChannel(NotificationManager notificationManager, public static void createNotificationChannel(NotificationManager notificationManager,

View File

@ -347,7 +347,6 @@ public class PushUtils {
if (readPublicKey) { if (readPublicKey) {
keyString = keyString.replaceAll("\\n", "").replace("-----BEGIN PUBLIC KEY-----", keyString = keyString.replaceAll("\\n", "").replace("-----BEGIN PUBLIC KEY-----",
"").replace("-----END PUBLIC KEY-----", ""); "").replace("-----END PUBLIC KEY-----", "");
;
} else { } else {
keyString = keyString.replaceAll("\\n", "").replace("-----BEGIN PRIVATE KEY-----", keyString = keyString.replaceAll("\\n", "").replace("-----BEGIN PRIVATE KEY-----",
"").replace("-----END PRIVATE KEY-----", ""); "").replace("-----END PRIVATE KEY-----", "");

View File

@ -42,7 +42,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public class ShareUtils { public class ShareUtils {
private static final String TAG = "ShareUtils";
public static String getStringForIntent(Context context, @Nullable String password, UserUtils userUtils, Room public static String getStringForIntent(Context context, @Nullable String password, UserUtils userUtils, Room
room) { room) {

View File

@ -37,7 +37,6 @@ import io.requery.query.Result;
import io.requery.reactivex.ReactiveEntityStore; import io.requery.reactivex.ReactiveEntityStore;
public class UserUtils { public class UserUtils {
private static final String TAG = "UserUtils";
private ReactiveEntityStore<Persistable> dataStore; private ReactiveEntityStore<Persistable> dataStore;
UserUtils(ReactiveEntityStore<Persistable> dataStore) { UserUtils(ReactiveEntityStore<Persistable> dataStore) {

View File

@ -89,6 +89,7 @@ class SSLSocketFactoryCompat(trustManager: X509TrustManager) : SSLSocketFactory(
cipherSuites = _cipherSuites.toTypedArray() cipherSuites = _cipherSuites.toTypedArray()
} }
} catch (e: IOException) { } catch (e: IOException) {
// Exception is to be ignored
} finally { } finally {
socket?.close() // doesn't implement Closeable on all supported Android versions socket?.close() // doesn't implement Closeable on all supported Android versions
} }

View File

@ -56,7 +56,6 @@ import java.util.Set;
public class MagicAudioManager { public class MagicAudioManager {
private static final String TAG = "MagicAudioManager"; private static final String TAG = "MagicAudioManager";
private static final String SPEAKERPHONE_AUTO = "auto"; private static final String SPEAKERPHONE_AUTO = "auto";
private static final String SPEAKERPHONE_TRUE = "true";
private static final String SPEAKERPHONE_FALSE = "false"; private static final String SPEAKERPHONE_FALSE = "false";
private final Context magicContext; private final Context magicContext;
// Contains speakerphone setting: auto, true or false // Contains speakerphone setting: auto, true or false
@ -91,7 +90,7 @@ public class MagicAudioManager {
private MagicProximitySensor proximitySensor = null; private MagicProximitySensor proximitySensor = null;
// Contains a list of available audio devices. A Set collection is used to // Contains a list of available audio devices. A Set collection is used to
// avoid duplicate elements. // avoid duplicate elements.
private Set<AudioDevice> audioDevices = new HashSet<AudioDevice>(); private Set<AudioDevice> audioDevices = new HashSet<>();
// Broadcast receiver for wired headset intent broadcasts. // Broadcast receiver for wired headset intent broadcasts.
private BroadcastReceiver wiredHeadsetReceiver; private BroadcastReceiver wiredHeadsetReceiver;
// Callback method for changes in audio focus. // Callback method for changes in audio focus.
@ -546,9 +545,10 @@ public class MagicAudioManager {
bluetoothManager.updateDevice(); bluetoothManager.updateDevice();
} }
if (needBluetoothAudioStart && !needBluetoothAudioStop) {
// Attempt to start Bluetooth SCO audio (takes a few second to start). // Attempt to start Bluetooth SCO audio (takes a few second to start).
if (!bluetoothManager.startScoAudio()) { if (needBluetoothAudioStart &&
!needBluetoothAudioStop &&
!bluetoothManager.startScoAudio()) {
// Remove BLUETOOTH from list of available devices since SCO failed. // Remove BLUETOOTH from list of available devices since SCO failed.
audioDevices.remove(AudioDevice.BLUETOOTH); audioDevices.remove(AudioDevice.BLUETOOTH);
audioDeviceSetUpdated = true; audioDeviceSetUpdated = true;
@ -620,13 +620,12 @@ public class MagicAudioManager {
private static final int STATE_UNPLUGGED = 0; private static final int STATE_UNPLUGGED = 0;
private static final int STATE_PLUGGED = 1; private static final int STATE_PLUGGED = 1;
private static final int HAS_NO_MIC = 0; private static final int HAS_NO_MIC = 0;
private static final int HAS_MIC = 1;
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
int state = intent.getIntExtra("state", STATE_UNPLUGGED); int state = intent.getIntExtra("state", STATE_UNPLUGGED);
int microphone = intent.getIntExtra("microphone", HAS_NO_MIC); // int microphone = intent.getIntExtra("microphone", HAS_NO_MIC);
String name = intent.getStringExtra("name"); // String name = intent.getStringExtra("name");
hasWiredHeadset = (state == STATE_PLUGGED); hasWiredHeadset = (state == STATE_PLUGGED);
updateAudioDeviceState(); updateAudioDeviceState();
} }

View File

@ -53,9 +53,7 @@ public class MagicPeerConnectionWrapper {
private static String TAG = "MagicPeerConnectionWrapper"; private static String TAG = "MagicPeerConnectionWrapper";
List<IceCandidate> iceCandidates = new ArrayList<>(); List<IceCandidate> iceCandidates = new ArrayList<>();
private PeerConnection peerConnection; private PeerConnection peerConnection;
private List<PeerConnection.IceServer> iceServers;
private String sessionId; private String sessionId;
private String localSession;
private String nick; private String nick;
private MediaConstraints mediaConstraints; private MediaConstraints mediaConstraints;
private DataChannel magicDataChannel; private DataChannel magicDataChannel;
@ -73,8 +71,6 @@ public class MagicPeerConnectionWrapper {
MediaConstraints mediaConstraints, MediaConstraints mediaConstraints,
String sessionId, String localSession, MediaStream mediaStream) { String sessionId, String localSession, MediaStream mediaStream) {
this.iceServers = iceServerList;
this.localSession = localSession;
this.localMediaStream = mediaStream; this.localMediaStream = mediaStream;
this.sessionId = sessionId; this.sessionId = sessionId;

View File

@ -111,12 +111,11 @@ public class MagicProximitySensor implements SensorEventListener {
@Override @Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) { public final void onAccuracyChanged(Sensor sensor, int accuracy) {
threadChecker.checkIsOnValidThread(); threadChecker.checkIsOnValidThread();
if (sensor.getType() == Sensor.TYPE_PROXIMITY) { if (sensor.getType() == Sensor.TYPE_PROXIMITY &&
if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) { accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
Log.e(TAG, "The values returned by this sensor cannot be trusted"); Log.e(TAG, "The values returned by this sensor cannot be trusted");
} }
} }
}
@Override @Override
public final void onSensorChanged(SensorEvent event) { public final void onSensorChanged(SensorEvent event) {

View File

@ -11,7 +11,8 @@ import static org.junit.Assert.*;
*/ */
public class ExampleUnitTest { public class ExampleUnitTest {
@Test @Test
public void addition_isCorrect() throws Exception { public void additionIsCorrect() throws Exception {
assertEquals(4, 2 + 2); assertEquals(4, 2 + 2);
} }
} }