Boolean expressions that can involve logical operators, used for branching execution paths, which increases cyclomatic complexity.

learn more… | top users | synonyms (2)

0
votes
1answer
56 views

Code for finding repeated entries with different data

project is the data frame. For the purpose of the code, HOUSE.NO is a column of the type character, and ...
0
votes
0answers
15 views

The Same Behavior for Boolean and Exception

The following code uses a boolean preference active: In the active state, it does an operation which could throw an exception. On this exception, it does fall back ...
-2
votes
3answers
138 views

Executing a query with or without bound variables

I know there's a more compact way of doing the following code but I haven't been coding PHP in a while and I completely forgot how. Pretty sure its to do with : and ...
3
votes
1answer
100 views

Using a Boolean method that never returns “false” to check user permissions

I need to check that a user is allowed to save/retrieve contacts to/from the database by calling a web service, and return an HTTP403 with an explanation if it is not the case. So for the sake of ...
1
vote
1answer
63 views

Mapping a product its corresponding image file

I'm writing this method that elaborates an image name.. I think my logic is not being the best one here but I'm not very savvy in programming yet. Right now it looks like this: ...
-2
votes
2answers
69 views

Assigning variables inside if else with PHP [closed]

Is this considered good coding practice? I am getting the unique_id from get_unique_id_for_username but if that function ...
-1
votes
1answer
42 views

Add an HTML body class depending on specific conditions if a block region is present on the web page or not

I wrote this code and I am wondering if there is a better way to phrase this. I was considering switch case but I was not sure how to translate this code into that. The purpose of this code is to ...
8
votes
4answers
2k views

Selecting an enum for a payment transaction

I'm writing a small Android application that deals with payments and, in my function that handles transactions, I need to translate a number of installments (1-12) and whether or not it has interest ...
4
votes
0answers
44 views

Determining the HTTP status code to return for a request

I have a piece of code that I would like to refactor but can't figure how to do it. This is a method from a Play controller where I have to verify many precondition and respond different status for ...
4
votes
4answers
194 views

Validating a tab-delimited string

This code checks if string has correct format for passing to struct. Correct format needs to be [123456789'\t'First Name'\t'Last Name'\t'City]. I didn't know how to ...
4
votes
1answer
59 views

C++ idiom for selecting integers from a vector according to predetermined properties

I want a function Select that takes a vector<int> and a condition (such as being even, being divisible by three, being ...
1
vote
2answers
71 views

Recreating a URL string

This is what my viewObject looks like: ...
15
votes
6answers
5k views

“Have a safe trip”… or not, depending on four conditions

I have 4 booleans and all must be met to determine the value of a String: ...
5
votes
1answer
111 views

Is date 18+ years old?

Considering that: the passed parameters are all numbers the passed date is a valid date It should return: true if the date is 18 or more years old ...
6
votes
1answer
45 views

A global Enum for comparison operators

This approach was born out of wanting to pass a logical expression (E.G. ">=10000") as a parameter to a function. So, I built an Enum and a function to use it to evaluate logical expressions. Is ...
1
vote
1answer
30 views

Choosing the desired icon when fetching results

I'm creating a Q&A website, Something like SO. Now I need to print a "check" icon (to specify accepted answer) next to every answer. Now there are some conditions: Is the current user logged? Is ...
0
votes
0answers
32 views

Special-case sprite positioning

I have several objects which are assigned a certain size and position, works fine. The only problem is that in certain special cases the item has to be positioned a bit to the left and be a bit ...
6
votes
2answers
308 views

Counting persons in each age range

I am calculating the number of people within a given age range. This is my current approach. Note: The persons is a ...
15
votes
2answers
323 views

Count the occurence of nucleobases in DNA string

Inspired by this meta question I decided to take a look at Rosalind. Their first challenge seemed easy enough: An example of a length 21 DNA string (whose alphabet contains the symbols 'A', 'C', ...
4
votes
1answer
54 views

Visualizing Brainf_ck interpreter in ClojureScript

I have written a working Brainfuck interpreter using ClojureScript, reagent, core.async and dommy. I am not very satisfied with the code, however, in particular the central part of the code - the ...
4
votes
0answers
68 views

Raw filter with ternary operator for html class attribute

I've been trying to figure out how to stop Twig escape using the following code, which I feel is a little nicer with the succinct ternary operator. Hoping someone can confirm I'm using the correct ...
2
votes
2answers
71 views

Rating the quality of a response based on the number of typos

I have this method which returns the number, but Rubocop said: Assignment Branch Condition size for rating is too high. [15.84/15] ...
4
votes
1answer
428 views

Is there anything wrong with this double ternary?

Is there anything wrong with using double ternary operator like so: ...
2
votes
2answers
75 views

Improving Custom Comparator.compare() method

I have the class SeguimientoSeccion with this relevant attributes ...
1
vote
2answers
64 views

Checking array for tags

I call a service which returns an array of tags. The array may be empty, and if so, it just saves the tag. Otherwise, it checks if the tag is in the array. If so, then the tag is removed, otherwise ...
1
vote
1answer
83 views

Zip the contents of subfolders, conditionally

I've written a script in Powershell for zipping files into new folders. This script performs the following steps: Check whether each subfolder contains non-zip files which are older than 31 days If ...
2
votes
1answer
33 views

Get time table from 4 attributes

I have an entity with opening and closing times and I have to list timetable in HTML label. Times can be empty. Ugly attribute names ...
3
votes
2answers
268 views

Most efficient FizzBuzz solution in Ruby

I would appreciate any feedback concerning my analysis of the most efficient FizzBuzz solution programmed in Ruby. I submit that a Case-statement solution is more efficient than utilizing a ...
-1
votes
3answers
78 views

Counting questions and chapters

I have the following if statement: ...
10
votes
4answers
344 views

Class to verify if a rectification is upgradable

Today I encountered something that I have been wondering about in the past a few times before. How can I refactor a method that has this format: ...
18
votes
6answers
3k views

Rock, Paper, Scissors, Lizard and Spock

I am currently done with this little Rock, Paper, Scissors, Lizard, Spock game in JavaScript. The game is working fine, but I am not pleased with the code. Is there a way to refactor these ...
11
votes
6answers
3k views

Writing the condition x <= y AND x > 0

My current condition is written as follows: ...
7
votes
6answers
453 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
4
votes
2answers
94 views

Marking a new dataTable row as consumed or cancelled

This is working code from a dataTable, which shows the function executed after the row is created: ...
0
votes
1answer
125 views

Processing selected and deselected elements

I think that this code is very bad because it does not agree with DRY principle. Can you advise me how to improve it? ...
2
votes
1answer
162 views

Rendering different view classes based on the value of a string

Here I'm instantiating different classes based on the value of a type property. This type property will determine what view is ...
-1
votes
1answer
57 views

Simple JavaScript Ternary

I need to set unit's exhaust. A unit might have a ...
2
votes
1answer
42 views

Converting any CSS colour to RGB(a)

For a plugin I'm writing in jQuery I have two optional parameters. For each parameter I do a check for its value. However, I'm curious if I can't write it shorter. Here is the fiddle and here's the ...
2
votes
1answer
103 views

Intercept URL containing values or not

I need to intercept a URL and go outside the WebView if the URL contains MAPS or DOCUMENTS ...
2
votes
1answer
60 views

Fields are required, except if all fields are empty

I have a group of four inputs, the first three are required, the fourth is optional. $fieldA $fieldB $fieldC $fieldD #Optional So to validate the inputs, I ...
-4
votes
1answer
70 views

Determining request status

This code gets request status based on request type and some mapping info. I'm wondering if there is a way to write nice conditional expressions in if statement. Expression should test if ...
-1
votes
1answer
65 views

Tried to change a if-else condition, but can it be better?

I recently came across this code snippet, and I have tried to change it. ...
6
votes
2answers
68 views

Handling calculator keypresses

I've added decimal (floating point) functionality to my calculator implementation; it's working but I'm having trouble making it more concise and less ugly. I'm trying to use the same method to ...
5
votes
2answers
123 views

Forming a dictionary where all values are only conditionally set

I have lots of dictionary keys with conditional values, ternary in this case: ...
4
votes
5answers
243 views

Class that represents a conditional expression

I have a class with which I want to persist a conditional expression: boolean x = a [GT] i I am only concerned with the ...
-1
votes
2answers
112 views

Validating input data

How can I simplify this? ...
1
vote
2answers
158 views

Seemingly redundant conditionals…or not?

I'm working on some code that has the following pattern of conditionals inside it. It doesn't look great, but it doesn't look terrible. Please, shed some light on the underlying reason this is not ...
3
votes
2answers
103 views

Composing terminal control sequences

I've seen everybody claims the nested ternary to be an evil even when an operation couldn't be written with switch-case; and here's even more, my code could be easily written with switch-case ...
1
vote
1answer
545 views

Changing DICOM tags using dcm4che

I am stuck on a piece of code that I have written that uses dcm4che. I have made a whole heap of nested ifs and I want to find a way to convert to a switch-case (problem being I have no way of ...
4
votes
2answers
74 views