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

learn more… | top users | synonyms (2)

-1
votes
0answers
27 views

Yes/no output using AngularJS

I get data from a database which I dont have access to modify. I display that data in my AngularJS project. A part of data is equipment of a property: if the eq1 ...
5
votes
1answer
102 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 ...
4
votes
1answer
31 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
27 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
292 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
305 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
42 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
58 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
63 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
427 views

Is there anything wrong with this double ternary?

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

Improving Custom Comparator.compare() method

I have the class SeguimientoSeccion with this relevant attributes ...
1
vote
2answers
63 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
45 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
32 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
230 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
77 views

Counting questions and chapters

I have the following if statement: ...
10
votes
4answers
342 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
445 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
4
votes
2answers
89 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
56 views

Simple JavaScript Ternary

I need to set unit's exhaust. A unit might have a ...
2
votes
1answer
41 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
94 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
56 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
67 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
64 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
63 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
114 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
240 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
111 views

Validating input data

How can I simplify this? ...
1
vote
2answers
156 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
93 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
425 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
69 views
2
votes
3answers
3k views

Filtering a list based on a value

Based on dropdown value and search text I need to filter a list and return. Method 1 ...
1
vote
1answer
284 views

Filtering a list based on conditions

I'm currently filtering a list based on several conditions, which may or may not be present: ...
6
votes
2answers
996 views

Simplified if return suggestion from Android Studio

I have this very simple method: ...
1
vote
1answer
37 views

A shorter way for getting variables

I have the following piece of code in my project, and that a few times: ...
8
votes
3answers
333 views

“Alien” distinguisher

I am practicing some simple Java coding problems in an attempt to learn while doing them. I would like to know if my code is redundant/is there an easier way to accomplish the same thing? Question: ...
5
votes
1answer
88 views

Effective use of branch prediction in terrain generator

I am trying to learn how branch optimization works. For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary ...
3
votes
2answers
220 views

Multiple attempts to find the best icon

I have a series if statements where I am trying to find the highest resolution file in an set of files. Is there a way that I can refactor this code to be shorter and or cleaner? ...
6
votes
1answer
2k views

Cash Register Challenge

Challenge: Design a cash register program Specifications: Your register currently has the following bills/coins within it: 'PENNY': .01, 'NICKEL': .05, 'DIME': .10, 'QUARTER': .25, ...
1
vote
1answer
67 views

Faking a pass method when building an array

Ruby doesn't have a pass method to 'do nothing' the way Python does - if I want a ternary statement to do something on true, but nothing on false (as in the code below) is it bad practice in Ruby to ...
4
votes
1answer
65 views

Executing a list of tasks from a database

I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly. Currently I have implemented this in the following way: ...
3
votes
3answers
105 views

Converting a state from hash into a JavaScript object

This code gets a state from a query string hash part, converts the hash part to a JavaScript object and then tries to get a view, ...
8
votes
3answers
878 views

Writing multiple if tags that compare two variables

I am a beginner in C# coding, and I was trying to compare two int variables: ...