643 questions
Best practices
1
vote
5
replies
78
views
Is passing the same value to a function twice bad practice?
this program prints a pyramid (its from a cs50 problem set). I call the function recursively by decrementing n, but i also wanted to keep track of its initial value in all the loops after the first ...
2
votes
1
answer
103
views
How can I make my Node.js backend code cleaner without using an ORM when working directly with SQL?
I'm building a Node.js backend using plain SQL (no ORM, just mysql2 wrapped in a small helper).
However, as my project grows, my route handlers start looking messy — full of raw SQL strings embedded ...
0
votes
0
answers
41
views
Using `npx knip` to find all unused .svg imports in JS/TS project?
I have a React Native project where I import a lot of .svg files into my components.
How can I use npx knip to find all unused svg files, just like it has found all unused .js/tsx files?
This is my ...
0
votes
0
answers
44
views
Angular Global Same Logic Functions Refactoring
I am trying to atleast clean the component.ts using services or somthing in my angular i have many repetitive code that i trying to fix and refactor. I am trying to apply DRY as possible can i have a ...
0
votes
2
answers
34
views
Why is resharper cleanup code adding a "plus" sign in app.config
When I run ReSharper cleanup code on a project, it adds a plus (+) sign.
Is this a feature, or how do I disable it?
<?xml ver.......>
+
<!--
...
...
-->
0
votes
0
answers
41
views
How to structure a form with reusable components while maintaining proper validation management?
Description:
I'm working on a Vue/Nuxt project where we typically create a single component that handles all inputs, their state, validation, and submission to the API.
While this approach works, it ...
0
votes
0
answers
38
views
How to run async operation and wait before node process ends?
I am building a simple apm.
I batch events and store them in db batched.
I also want to store anything left in the batch once the process ends/killed/error
This is my code
export function startApm(): ...
1
vote
0
answers
34
views
Cleaning up code with function or extension
I have texts and text fields with the same modifiers. Instead of copying and pasting them every time, is there a way to clean them up so they're called like functions or extensions?
Is there a way to ...
1
vote
0
answers
243
views
JetBrains Rider removing space between delegate keyword and parenthesis
On my team, some of us use Rider, others use Visual Studio 2022. When they run code cleanup, VS 2022 adds a space between delegate and () as seen here:
var cat = this.ExecuteAFunction("Function ...
0
votes
1
answer
768
views
Visual Studio Code Cleanup: How to avoid removing unassgiend/unused variable when file is on save
I am using Code Cleanup in Visual Studio and noticed when file is on save.
The unused variable will be removed like:
I tried editing the .editorConfig file but it didn't seem to work with any of the ...
0
votes
0
answers
74
views
Getting "MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it." after I stop play mode
I'm still learning Unity. I have quite a few objects and scripts in the scene and they interact with each other. I'm getting "MissingReferenceException: The object of type 'GameObject' has been ...
-2
votes
1
answer
349
views
Run cleanup function in Python when Jenkins job is aborted
I wrote a script in Python that is running for some time and performing a clean up as soon as it terminates regularly like:
import time
def cleanUp():
#delete some temporary files and so on
...
2
votes
2
answers
4k
views
React-query infiniteQuery - how to fix additional pageParam type checking
i have bumped into following issue, i'm trying to implement infiniteQuery by using react-query tanstack, but i can't do it without additional checking of pageParam on it's type of number.
Could you ...
2
votes
2
answers
950
views
C# - VS2022: "global using" and code cleanup on save
In VS2022 I turned on the very useful feature "Run Code Cleanup profile on Save".
With this option on, every unneeded using statement in code gets removed automatically on save.
Now I would ...
0
votes
0
answers
1k
views
How to use Playwright locators to replace evaluateAll and querySelector?
I'm trying to get data from a webpage using Playwright in TypeScript. I have a section of code where I want to extract information from multiple elements matching a certain locator.
However, I'm ...
4
votes
0
answers
302
views
In c# code cleanup, How to stop visual studio 2022 adding comments /* Unmerged change from project 'xxxx (net6.0)'
Environment:
Visual studio 2022, v17.8.3 with net8 support
I did cleanup to c# solution with 6 projects using profile2 .
I found that vs 2022 during code cleanup using profile2 add these like ...
0
votes
1
answer
184
views
I want to read in a csv file to a .NET datatable with respect to data column datatypes
I have a way to do this that works as shown below, but I really want to see if there is a cleaner way to do this without using a CSV library or package.
public static void Read(string ...
0
votes
1
answer
126
views
Socket connection does not disconnect at useEffect cleanup function
I have this code :
useEffect(() => {
const init = async () => {
try {
socketRef.current = await initSocket();
socketRef.current.on("connect_error", (err) =&...
1
vote
1
answer
997
views
How to Organize Compose Imports by Moving Them to Another File and Importing in Another Screen?
I'm working on an Android project using Jetpack Compose, and I have a screen with a long list of imports at the top. I want to clean up the code and make it more organized. Is there a way to move ...
2
votes
1
answer
123
views
Code cleanup adds spaces in interpolated strings
I have a problem with Resharper code cleanup, it turns out that there is some collision/setting in my editor config that causes spaces to be added in the interpolated text, spoiling the result. The ...
0
votes
1
answer
299
views
Delete sensitive string from all Git commits
I have internal github in our organization. There is a particular git repo where I need to replace a sensitive string from all commits. There are around 2000 commits and the sensitive string is there ...
0
votes
0
answers
67
views
Is there a way to optimize a triple nested loop for accessing and object
I need to build a application to extract data from multiple JSON-Files and store it into a Database.
The File looks like this and parsed results in a highly nested object.
To explain, i need to go ...
1
vote
1
answer
474
views
Checkstyle for unused member variables?
Need the checkstyle configuration for unused member variables.
There exists a checkstyle like below, but's just for local variables.
<module name="UnusedParameterCheck"/>
( Needed a ...
1
vote
1
answer
348
views
What's the order of operations of a cleanup function inside a useEffect to clean stale effects?
I’m currently learning about the cleanup function in useEffect but I’m stuck on how it works in this particular example. I’m specifically stuck in the order of operations.
Looking at the last three ...
0
votes
0
answers
1k
views
How to identify unused methods, codes, libraries and references in VScode
Team,
I need to identify & remove unused variables (arguments, local variables, class member variables), Libraries, and references that are unused in VS code.
I have also tried to find out some ...
-2
votes
1
answer
47
views
There is a way to create a sequence of "if"s with textBox and method changes programmatically (C#)?
I have a form with two groupBoxes with various radioButtons each;
When selecting one of them, I want to change the texts in textboxes (in each groupBox);
Currently using this sequence of "if's&...
1
vote
0
answers
98
views
Refactor validation with return if statement
I have lots of method and on each method I have to do a validation. Currently, my code look like this and it works fine.
@Service
public class UserService {
@Autowired
private UserValidation ...
2
votes
0
answers
187
views
Why does "dotnet_style_prefer_is_null_check_over_reference_equality_method = true" not recognize "foo == null"?
I decided to switch from foo == null checks to foo is null. Instead of having to search through all of my code, I set dotnet_style_prefer_is_null_check_over_reference_equality_method = true in my ....
3
votes
1
answer
2k
views
How can I remove unused code from a nx workspace project libs (Most libs are in Angular - typescript)?
We already have set up eslint rules (no-unused-vars) to detect unused vars and also unused imports.
What we are struggling to find is unused components, state management codes, css styles and unused ...
-2
votes
2
answers
322
views
What is the best way to write a class with editable properties that becomes read-only after the method is called?
I have solved my problem in the way I will describe below but I want to find the best way.
Typescript has generic type Readonly that solved this problem.
Thanks for your suggests
I used folowing codes ...
1
vote
0
answers
31
views
How can I group and name the incoming values in the request according to the standards in the config-repo with Springboot?
In the request, I will receive a Solr-name field of type List. I need to group by solr-name name. For example, gender_s, age_f and job_s came. If these three come, I have to assign them as ...
-3
votes
2
answers
121
views
How to remove the amounts of ifs from the application? [closed]
The code I say has to complete these assignments:
Given an integer,N, perform the following conditional actions:
If N is odd, print Weird
If N is even and in the inclusive range of 2 to 5 , print Not ...
0
votes
1
answer
193
views
Is there anyway to detect or intercept if a program is forcbily quit/terminated in a injected DLL?
I want to perform a cleanup procedure for my injected DLL before the injected application terminates. So I'm looking for a way to intercept ExitProcess, TerminateProcess or any termination in general.
...
0
votes
0
answers
52
views
Is there any way to input a range of languages for the :lang() pseudo-class?
I'm targeting a bunch of different languages in my LESS/CSS with the :lang() pseudo-class. It looks like this (but even more languages):
:lang(af),
:lang(sq),
:lang(eu),
:lang(bs),
:lang(ca),
:lang(kw)...
6
votes
1
answer
1k
views
Code-Cleanup in VS2022 applies different tab/space formatting rules for closed solution files
Why would the VS2022 Code-Cleanup feature apply different keep-tabs formatting preferences depending on whether a source file is being viewed in VS2022 or is closed?
I have a new VS2022 install on a ...
0
votes
1
answer
74
views
Refactoring methods that use the same code but different input params
I have these two methods. Can someone help me to refactor and make them common?
public void method1(Map<String,String> map, String key, String value){
map.put(key, value);
}
public void ...
0
votes
2
answers
456
views
Remove ")" from cells in list if ")" exists
Could you please tell me how can I remove ")" from strings in a list without converting the list to a string? Example:
Input:
list =[
'ABDDDDC 1,000 IWJBCKNBCDVV',
'BDISJBJ 2,000 ...
10
votes
1
answer
2k
views
Code Cleanup doesn't do Format document in Visual Studio 2022
I have the following settings regarding my Tab sizing in Visual Studio 17.4.1:
When I use Edit->Advanced->Format Document, I get this result:
I configured Code Cleanup which allegedly contains ...
0
votes
1
answer
735
views
How to clean up function that is outside useEffect?
I have a resend code button and will disable it for 30sec after pressed. Here is my function.
const time = useRef(30);
function disableResendBtn() {
time.current = 30;
...
-2
votes
1
answer
428
views
How I can make this messy code a little bit more clean?
I'm a newbie in coding javascript, to be honest there is a lot of things I don't understand but i always manage to make things work. I wrote something for odin project but i'm sure it's not as clean ...
0
votes
1
answer
96
views
How can I refactor these two functions with repeating code?
I'm trying to refactor my code for higher readability and I'm new to this.
I have two functions called UpFirst() and RightFirst() and they include common lines of code and I want to clean the ...
0
votes
0
answers
32
views
Remove Redundant Python dependencies which are not used anywhere in the environment [duplicate]
I have an application with plenty of third-party packages in it, some of them are not required, and few packages have many versions installed in the environment.
Is there any tool or method to detect ...
4
votes
2
answers
3k
views
Python tempfile.TemporaryDirectory() cleanup crashes with PermissionError and NotADirectoryError
Premise
I'm trying to convert some PDF to images via pdf2image and poppler, to then run some computervision tasks on.
The conversion itself works fine.
However, the conversion creates some artifacts ...
1
vote
0
answers
439
views
How to cleanup Google AdSense errors in React 18 with new useEffect hook automatic remounting behaviour?
I am building a next.js website and intend to include Google AdSense at some point in the future. After following some examples and implementing the scripts as per a Next project I am hitting a wall ...
0
votes
1
answer
321
views
nodejs check multiple constants and give specific error message for the missing constants
I am currently creating an API for posting in backend with nodejs.
My data object, which gets provided from the frontend contains multiple objects.
My first step is to check if these multiple consts ...
1
vote
1
answer
5k
views
How to apply styles to TabPane in new Antd Tabs component
This is my old implementation of the Tabs component in Ant Design.
const tabList = [
{
key: "tab1",
label: "Tab1",
children: <Tab1 />,
},
{
key: "...
0
votes
1
answer
646
views
Best way to reset a ruby on rails project
We have a ruby rails project which we normally get from our enterprise github repository. Recently, I've added dependencies that for some reason breaks my other projects that are not related to the ...
0
votes
1
answer
30
views
how do i break this python loop in a efficent manner after ive entered a valid number
while True:
month_num = int(input("enter the month number: "))
if month_num == 1:
print("january")
elif month_num == 2:
print("February")
...
0
votes
1
answer
613
views
What is the most efficient way to write this retry logic for a try-catch? C# [closed]
I have a C# task that I'd like to re run if a certain exception type is thrown.
This is what I have currently:
bool retry = true;
int numOfRetries = 3;
int tries;
while (retry = true && tries ...
0
votes
1
answer
502
views
How Can I run automatic code cleanup in VS 2022 on just the modified lines on save?
I found the code cleanup options but I want to apply them only on lines that have been edited and not the entire file. Is this possible to achieve?