Showing 387 of 387 total issues
RecordingFragment
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
public class RecordingFragment extends Fragment implements RecordingContract.View {
public static final String ARGUMENT_APIARY_ID = "APIARY_ID";
public static final String ARGUMENT_HIVE_ID = "HIVE_ID";
public static final String ARGUMENT_START_DATE = "START_DATE";
ApiariesFragment
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
public class ApiariesFragment extends Fragment
implements ApiariesContract.View, ApiaryItemListener {
private ApiariesContract.LoadDataPresenter presenter;
private ApiariesAdapter listAdapter;
Similar blocks of code found in 2 locations. Consider refactoring. Open
@Override
public boolean checkCameraPermission() {
// Check camera permission
if (PermissionUtils.isGranted(getActivity(), PermissionEnum.CAMERA)) {
return true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 179.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
@Override
public boolean checkLocationPermission() {
// Check location permission
if (PermissionUtils.isGranted(getActivity(), PermissionEnum.ACCESS_FINE_LOCATION)) {
return true;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 179.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method onCreateView
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.monitoring_frag, container, false);
Method listHivesTest
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void listHivesTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_apiary),
withParent(withId(R.id.coordinatorLayout)),
MonitoringSettingsFragment
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
public class MonitoringSettingsFragment extends PreferenceFragment
implements MonitoringContract.SettingsView, Preference.OnPreferenceChangeListener {
private MonitoringContract.Presenter presenter;
private RelativeLayout settingsLayout;
Method viewRecordingTest
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void viewRecordingTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_apiary),
withParent(withId(R.id.coordinatorLayout)),
File GoBeesRepository.java
has 273 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* GoBees
* Copyright (c) 2016 - 2017 David Miguel Lozano
*
* This program is free software: you can redistribute it and/or modify
Method formatWind
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static String formatWind(Context context, double windSpeed, double deg) {
int windFormat = R.string.format_wind_kmh;
double value;
if (!GoBeesPreferences.isMetric(context)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method addRecordingTest
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void addRecordingTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_apiary),
withParent(withId(R.id.coordinatorLayout)),
Method deleteRecordingTest
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void deleteRecordingTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_apiary),
withParent(withId(R.id.coordinatorLayout)),
Log
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
@SuppressWarnings({"unused", "WeakerAccess"})
public class Log {
private Log() {
// Utility class
Apiary
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
@SuppressWarnings("unused")
public class Apiary extends RealmObject {
@PrimaryKey
private long id;
Method editHiveTest
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void editHiveTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_apiary),
withParent(withId(R.id.coordinatorLayout)),
Method parseCurrentWeatherJson
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void parseCurrentWeatherJson() throws Exception {
String jsonResponse = "{\n"
+ " \"coord\":{\n"
+ " \"lon\":139,\n"
Method viewHiveTest
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void viewHiveTest() {
ViewInteraction floatingActionButton = onView(
allOf(withId(R.id.fab_add_apiary),
withParent(withId(R.id.coordinatorLayout)),
Method listRecordingsTest
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Test
public void listRecordingsTest() {
ViewInteraction appCompatImageButton2 = onView(
allOf(withContentDescription("Navigate up"),
MonitoringService
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
@SuppressWarnings("deprecation")
public class MonitoringService extends Service implements AndroidCameraListener {
// Intent argument
public static final String ARGUMENT_MON_SETTINGS = "MONITORING_SETTINGS";
File MonitoringService.java
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
* GoBees
* Copyright (c) 2016 - 2017 David Miguel Lozano
*
* This program is free software: you can redistribute it and/or modify