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
11 views

return value in multi if in python [on hold]

I'm doing a unit testing, I'm checking fields in two databases collections so during it I have to do a multi if conditions like this: ...
-1
votes
0answers
6 views

Passing Code to updateButtonLabel for TIC TAC TOe [closed]

I am incredibly new to coding as well as this website. This works for the most part except for win functions toward the bottom. It is supposed to be a Tic Tac Toe game board and it needs to display an ...
8
votes
3answers
216 views

Check if 2 rectangles fit in another one, given their length and height

I was very intrigued with the manner to solve this problem. The program needs to know if 2 rectangles fit in another one, considering the lines of the 2 rectangles are always parallel to the other one'...
4
votes
1answer
74 views

Biometric matching score calculator

I'm working on a biometric matching system and I would like to have few suggestions regarding vectorizing the following code: ...
3
votes
1answer
45 views

Redirecting to the appropriate URL for some type of notification

I have a polymorphic notification model with action attribute. When user clicks on a notification he/she should be redirected to given page the notification refers to through notifiable. What is the ...
5
votes
4answers
54 views

Two HTTP notification methods

I have two very similar methods, which make HTTP requests, the difference is that one makes PUT and another GET. Is there any proper Ruby way not to repeat the setup code and not to pass the flag ...
4
votes
1answer
63 views

Determining whether a task is active based on many conditions

I wrote a Rails model instance method that checks many separate conditions, and returns a single boolean. It does not employ any nesting of branching structures. Each check has its own comments ...
2
votes
1answer
60 views

PHP Custom $_GET checker function performance

I'm trying to follow the DRY programming philosophy and I am tired of running isset() and an if not empty statements for each ...
0
votes
1answer
68 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 ...
-2
votes
3answers
141 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
105 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
66 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: ...
-1
votes
1answer
44 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
1answer
73 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
198 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
62 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
73 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
118 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
58 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
31 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
340 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
336 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
55 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
76 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
430 views

Is there anything wrong with this double ternary?

Is there anything wrong with using double ternary operator like so: ...
2
votes
2answers
81 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 it'...
1
vote
1answer
165 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
35 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
295 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
79 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: ...
19
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
456 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
4
votes
2answers
101 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
163 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
58 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
112 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
61 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
70 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
138 views

Forming a dictionary where all values are only conditionally set

I have lots of dictionary keys with conditional values, ternary in this case: ...