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)
public class MagicFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = "MagicFirebaseInstanceIDService";
@Inject
AppPreferences appPreferences;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -184,12 +184,11 @@ public class ContactsController extends BaseController implements SearchView.OnQ
userEntity = userUtils.getCurrentUser();
if (userEntity == null) {
if (getParentController().getRouter() != null) {
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
.pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler())));
}
if (userEntity == null &&
getParentController() != null && getParentController().getRouter() != null) {
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
.pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler())));
}
if (adapter == null) {
@ -197,7 +196,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
adapter.setNotifyChangeOfUnfilteredItems(true)
.setMode(SelectableAdapter.Mode.MULTI);
if (userEntity != null) {
fetchData();
}

View File

@ -65,7 +65,6 @@ import io.reactivex.disposables.Disposable;
@AutoInjector(NextcloudTalkApplication.class)
public class SwitchAccountController extends BaseController {
private static final String TAG = "SwitchAccountController";
@Inject
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.base.BaseController;
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.utils.ShareUtils;
import com.nextcloud.talk.utils.bundle.BundleKeys;
@ -79,8 +78,6 @@ public class CallMenuController extends BaseController implements FlexibleAdapte
private MenuType menuType;
private Intent shareIntent;
private UserEntity currentUser;
public CallMenuController(Bundle args) {
super(args);
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) {
super.onViewBound(view);
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
currentUser = userUtils.getCurrentUser();
prepareViews();
}

View File

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

View File

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

View File

@ -21,5 +21,5 @@
package com.nextcloud.talk.interfaces;
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;
public class MagicJobCreator implements JobCreator {
private static final String TAG = "MagicJobCreator";
@Nullable
@Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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