Showing 436 of 436 total issues
Method processRequiredStepsField
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void processRequiredStepsField(Facts facts, JSONObject object) throws Exception {
if (object != null) {
Iterator<String> keys = object.keys();
while (keys.hasNext()) {
String key = keys.next();
Method onResumption
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onResumption() {
try {
fetchContactAndAlertStatus();
yamlConfigListGlobal = new ArrayList<>(); //This makes sure no data duplication happens
Method removeWomanFromANCRegister
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void removeWomanFromANCRegister(final String closeFormJsonString, final String providerId) {
Runnable runnable = () -> {
try {
Triple<Boolean, Event, Event> triple = ANCJsonFormUtils
Identical blocks of code found in 2 locations. Consider refactoring. Open
private void prefillInjectableFacts(Facts facts, String template) {
String[] relevanceToken = template.split(",");
String key;
for (String token : relevanceToken) {
if (token.contains("{") && token.contains("}")) {
- 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 101.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
private void prefillInjectableFacts(Facts facts, String template) {
String[] relevanceToken = template.split(",");
String key;
for (String token : relevanceToken) {
if (token.contains("{") && token.contains("}")) {
- 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 101.
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 onClick
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void onClick(View view) {
try {
//To show current date in the datepicker
Calendar mcurrentDate = Calendar.getInstance();
Method initializeLastContactDetails
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void initializeLastContactDetails(HashMap<String, String> clientDetails) {
if (clientDetails != null) {
try {
List<LastContactDetailsWrapper> lastContactDetailsWrapperList = new ArrayList<>();
List<LastContactDetailsWrapper> lastContactDetailsTestsWrapperList = new ArrayList<>();
Method processCheckBoxSpecialWidget
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void processCheckBoxSpecialWidget(JSONObject widget, List<String> keyList, List<String> valueList)
throws Exception {
//Clear previous selected values from the widget first
if (widget.has(JsonFormConstants.VALUE)) {
widget.remove(JsonFormConstants.VALUE);
Method saveImage
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void saveImage(String providerId, String entityId, String imageLocation) {
OutputStream outputStream = null;
try {
if (StringUtils.isBlank(imageLocation)) {
return;
Method getPreviousContactsFacts
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public List<PreviousContactsSummaryModel> getPreviousContactsFacts(String baseEntityId) {
List<PreviousContactsSummaryModel> previousContactFacts = new ArrayList<>();
Cursor factsCursor = null;
try {
SQLiteDatabase database = getWritableDatabase();
Method addTestsRuleObjects
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private List<YamlConfigWrapper> addTestsRuleObjects(Facts facts) throws IOException {
List<YamlConfigWrapper> lastContactTests = new ArrayList<>();
Iterable<Object> testsRuleObjects = AncLibrary.getInstance().readYaml(FilePathUtils.FileUtils.PROFILE_LAST_CONTACT_TEST);
for (Object ruleObject : testsRuleObjects) {
- 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 getListValuesAsString
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@SuppressLint("NewApi")
public static String getListValuesAsString(List<String> list) {
List<String> returnList = new ArrayList<>();
if (list.size() != 0) {
for (int i = 0; i < list.size(); i++) {
- 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 search
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. 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)) {
- 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 cleanValueResult
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private static String cleanValueResult(String result) {
List<String> nonEmptyItems = new ArrayList<>();
for (String item : result.split(",")) {
if (item.length() > 0 && StringUtils.isNotBlank(item)) {
nonEmptyItems.add(item);
- 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 saveSiteCharacteristics
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void saveSiteCharacteristics(Map<String, String> siteCharacteristicsSettingsMap) throws JSONException {
JSONArray localSettings;
JSONObject settingObject;
- 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 a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void onBindViewHolder(@NonNull PreviousContactsAdapter.ViewHolder viewHolder, int position) {
if (factsList.size() > 0) {
try {
String contactNo = String.valueOf(factsList.size() - position);
- 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 savePreviousTaskDetails
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private void savePreviousTaskDetails(String contactNo, Task task) {
try {
JSONObject taskValue = new JSONObject(task.getValue());
if (taskValue.has(JsonFormConstants.VALUE)) {
JSONArray value = taskValue.getJSONArray(JsonFormConstants.VALUE);
- 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 globalSearch
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private Response<String> globalSearch(Map<String, String> map) {
String baseUrl = getDristhiConfiguration().dristhiBaseURL();
String paramString = "";
if (!map.isEmpty()) {
for (Map.Entry<String, String> entry : map.entrySet()) {
- 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 onCreate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getViewLayoutId());
actionBar = getSupportActionBar();
Method process
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void process(String[] mainContactForms) {
//Fetch and load previously saved values
try {
if (contactNo > 1 && !PatientRepository.isFirstVisit(baseEntityId)) {
for (String formEventType : new ArrayList<>(Arrays.asList(mainContactForms))) {