Showing 306 of 436 total issues
Method getCurrentContactState
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
private String getCurrentContactState(String baseEntityId) throws JSONException {
List<PreviousContact> previousContactList = getPreviousContactRepository().getPreviousContacts(baseEntityId, null);
JSONObject stateObject = null;
if (previousContactList != null) {
stateObject = new JSONObject();
- 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 onBindViewHolder
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
if (!TextUtils.isEmpty(mData.get(position).getGroup())) {
Method getPreviousContacts
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public List<PreviousContact> getPreviousContacts(String baseEntityId, List<String> keysList) {
String orderBy = ID + " DESC ";
Cursor mCursor = null;
String selection = "";
String[] selectionArgs = null;
Method getTasks
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public List<Task> getTasks(String baseEntityId, List<String> keysList) {
String orderBy = ID + " DESC ";
Cursor mCursor = null;
String selection = "";
String[] selectionArgs = new String[]{};
Method populateLocationSpinner
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void populateLocationSpinner(JSONObject jsonObject, String parentLocationId, String spinnerKey,
List<String> controlsToHide) {
List<Location> locations = Utils.getLocationsByParentId(parentLocationId);
String selectedLocation = Utils.getCurrentLocation(spinnerKey, jsonFormView);
Method search
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void search(String firstName, String lastName, String ancId, String edd, String dob, String phoneNumber,
String alternateContact, boolean isLocal) {
String searchCriteria =
model.createSearchString(firstName, lastName, ancId, edd, dob, phoneNumber, alternateContact);
if (StringUtils.isBlank(searchCriteria)) {
Method processPopulatableFields
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected static void processPopulatableFields(Map<String, String> womanClient, JSONObject jsonObject)
throws JSONException {
AncMetadata ancMetadata = AncLibrary.getInstance().getAncMetadata();
Method createPreviousVisitFromGroup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static void createPreviousVisitFromGroup(@NonNull String strGroup, @NonNull String
baseEntityId) throws JSONException {
JSONObject jsonObject = new JSONObject(strGroup);
Iterator<String> repeatingGroupKeys = jsonObject.keys();
List<String> currentFormSubmissionIds = new ArrayList<>();
Method getWomanProfileDetails
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static Map<String, String> getWomanProfileDetails(String baseEntityId) {
Cursor cursor = null;
Map<String, String> detailsMap = null;
try {
Method onActivityResultExtended
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
protected void onActivityResultExtended(int requestCode, int resultCode, Intent data) {
if (requestCode == ANCJsonFormUtils.REQUEST_CODE_GET_JSON && resultCode == Activity.RESULT_OK) {
try {
String jsonString = data.getStringExtra(ConstantsUtils.JsonFormExtraUtils.JSON);
Method getAllTestResultsForIndividualTest
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public Facts getAllTestResultsForIndividualTest(String baseEntityId, String indicator, String dateKey) {
String orderBy = ID + " DESC ";
String[] selectionArgs = null;
String selection = "";
Method getButtonAlertStatus
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static ButtonAlertStatus getButtonAlertStatus
(Map<String, String> details, Context context, boolean isProfile) {
String contactStatus = details.get(DBConstantsUtils.KeyUtils.CONTACT_STATUS);
String nextContactDate = details.get(DBConstantsUtils.KeyUtils.NEXT_CONTACT_DATE);
Method onClick
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public void onClick(View view) {
getJsonApi().setPreviousPressed(false);
if (view.getId() == com.vijay.jsonwizard.R.id.next || view.getId() == com.vijay.jsonwizard.R.id.next_icon) {
Object tag = view.getTag(com.vijay.jsonwizard.R.id.NEXT_STATE);
Method onCreate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
Method addAttentionFlagsService
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected void addAttentionFlagsService() {
try {
JSONObject jsonObject = new JSONObject(AncLibrary.getInstance().getDetailsRepository().getAllDetailsForClient(pc.getCaseId()).get(ConstantsUtils.DetailsKeyUtils.ATTENTION_FLAG_FACTS));
Facts facts = new Facts();
Method processRequiredStepsField
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void processRequiredStepsField(JSONObject object) throws Exception {
if (object != null && object.has(ConstantsUtils.JsonFormKeyUtils.ENCOUNTER_TYPE)) {
//initialize required fields map
String encounterType = object.getString(ConstantsUtils.JsonFormKeyUtils.ENCOUNTER_TYPE);
Method createVisitAndUpdateEvent
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static Pair<Event, Event> createVisitAndUpdateEvent(List<String> formSubmissionIDs,
Map<String, String> womanDetails) {
if (formSubmissionIDs.size() < 1 && womanDetails.get(ConstantsUtils.REFERRAL) == null) {
return null;
}
Method createSavePdf
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void createSavePdf(Context context, List<YamlConfig> yamlConfigList, Facts facts,String womanName) throws FileNotFoundException {
String FILENAME = womanName+"_"+context.getResources().getString(R.string.contact_summary_data_file);
String filePath = getAppPath(context) + FILENAME;
Method initializeFirstContactValues
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static String initializeFirstContactValues(@NonNull JSONArray fields) throws JSONException {
String strGroup = null;
int nextContact = 1;
Method getImmediatePreviousContact
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public Facts getImmediatePreviousContact(Map<String, String> clientDetails, String baseEntityId, String contactNo) {
Facts facts = new Facts();
try {
facts = AncLibrary.getInstance().getPreviousContactRepository().getPreviousContactFacts(baseEntityId, contactNo, true);