7,969 questions
Tooling
0
votes
5
replies
96
views
A Clang tool to add extra line of code whenever a #define is true
I want to develop a tool that helps in transforming a code like this:
#ifdef MYLIB_ENABLE_DEPRECATED_CODE
... some deprecated code ...
#endif
into:
#ifdef MYLIB_ENABLE_DEPRECATED_CODE
...
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 ...
2
votes
0
answers
107
views
Android Studio automatically rewrites Kotlin code when copying a file
When I copy a .kt file from one project to another (or within the same project) in Android Studio Narwhal 3 Feature Drop | 2025.1.3, the IDE automatically modifies parts of my Kotlin code.
Example:
...
1
vote
2
answers
437
views
Flutter Outline completely missing on Android Studio
Android Studio Version: Android Studio Meerkat Feature Drop | 2024.3.2 Patch 1
Build #AI-243.26053.27.2432.13536105, built on May 22, 2025
I've been unable to find anyone with this issue, as it ...
1
vote
2
answers
101
views
How can I simplify a long if-else chain when setting JComboBox models based on enum categories?
I’m working on a Java Swing unit converter. The user selects a unit category from a JComboBox, and based on that selection, I update two other JComboBox<Units> with corresponding enum values (...
1
vote
1
answer
77
views
Custom hook inside custom hook pattern
I use Tanstack Query in my project and have arranged my api interactions like this (see below). Basically I made a custom hook inside which there are other hooks that do data fetching. In my opinion, ...
3
votes
2
answers
117
views
Replacement for using switch on enum value to access struct/union data member
I'm writing an emulator of a custom ISA 16-bit processor that has instructions with operands of different sizes in C (C23 standard). In my code, I use enum members to indicate the size of the operands,...
1
vote
1
answer
101
views
How to do find and replace with auto import?
Often times we want to import something into some files, and we determine those files by find and replace.
For example:
We want to find all files that has '/awesome-page', change to '/awesome-page' + ...
-3
votes
2
answers
108
views
How do I refactor an `@Input` which is being updated directly, which is not possible to do in `input` signal
I am refactoring my angular code to work with signals. I have this below code, which needs to be refactored.
@Component({ ... })
export class SomeComponent {
@Input() test = null;
ngOnInit() {
...
3
votes
0
answers
182
views
Usage of CSP /nonce on Electron app with Node.js
I'm making a desktop application with Electron and Node.js, in which I'm trying to implement CSP /nonce.
So far I have developed a script that should generate the content security policy:
const crypto ...
1
vote
0
answers
64
views
VSCode rename symbol ignores references in other files
I have a class attribute account_values that occurs multiple times in class MyClass, all in the same the file file1.py. It is also referenced multiple times in file2.py. All the references in file1.py ...
0
votes
0
answers
24
views
Is it possible to prove that a given AST transformation is a perfect reversal of another?
I want to use AST transformation using jscodeshift to do a large scale refactor, changing our test runner from Jest to Bun Test.
A concern that I'm trying to mitigate is that we might migrate the ...
-1
votes
1
answer
273
views
How do I move PyCharm project folder elsewhere?
I am using PyCharm Community Edition. I have a project folder, that I now need to move to another place on the same PC, on windows 11. I don't seem to be able to do that.
There are a lot of advice for ...
1
vote
0
answers
76
views
Refactoring marshmellow schema to pydantic 2
I have been struggling to refactor this marshmellow schema to pydantic 2. Problem is with AttributeValue field. When I refactor this to pydantic, I always get strange errors regarding this field. This ...
3
votes
2
answers
68
views
Is there a way to make the output from one bash command go to a user selected location?
I'm writing a bash script that amongst other things, starts a user specified command, sending the output to either file, file and stdout, or just stdout as required.
I don't like the duplication of ...
3
votes
1
answer
121
views
Can the order of declarations alter a program?
That is can you by altering the order of declaration still have a valid program, but with a different result. This question is not if you can turn a valid program into an invalid (which you obviously ...
0
votes
1
answer
60
views
How do I move a method in a Typescript project?
I am working with Playwright on a test automation project. I already have several Pages classes and would now like to move a method from one class to another. This already has various references.
Is ...
1
vote
1
answer
108
views
Is there anyway to make Java Custom Annotation Processor with RetentionPolicy SOURCE to work?
I have created a Java Custom Annotation Processor with RetentionPolicy as SOURCE for generating personalized code for me just like Lombok's Getter & Setter.
Unfortunately it didn't worked because ...
0
votes
1
answer
105
views
How can I highlight or select all Pandas code in Visual Studio Code
I want to transition from Pandas to Polars in a big Python project. Is there a way to highlight or find all Pandas commands I've written in Visual Studio Code (or another IDE if necessary) so I would ...
0
votes
1
answer
80
views
Remove un used files from core php project
I want to remove unused php files from my core php project. I have tried various static analysis tools like phpstan, phpDocumentor etc but it gives only the unused functions etc. I need to have the ...
0
votes
1
answer
63
views
reStructuredText: Fix section/headline level when including file
I have a couple of dozen .rst files that are all loaded from a main index.rst file via .. include: file.rst.
Now I want to restructure the TOC and move some files onto a different headline level - but ...
-2
votes
1
answer
37
views
Add type constraints on generic class that extends a parent and implements interfaces [closed]
In the class hierarchy below, how to define type constraint for T (where T : class, new())?
abstract class AbstractComponent<T> : Parent, IComponentType, IRelationship
{}
class ChildComponent : ...
1
vote
2
answers
85
views
Different results for function() and fn(). PHP
I have a problem.
$this->allIds->each(function ($id) {
$this->checked[$id] = $this->checkedAll;
});
And this:
$this->allIds->each(fn($id) => $this->checked[$id] = $this-&...
-2
votes
1
answer
63
views
How to replace package path easily? [closed]
Project/
├── a/
│ ├── core/
│ │ └── com.blabla.hi.sofbs
│ └── api/
│ └── com.blabla.hi.sofbs
└── b/
├── core/
│ └── com.blabla.hi.sofbq
└── api/
└── com.blabla.hi....
2
votes
1
answer
112
views
Add custom refactoring pattern using Resharper
I have hundreds occurences of this kind of lines in my app :
public ICommand MyCommandName => ReactiveCommand.Create(TriggerCommand);
I tried without luck to add a Custom Pattern in resharper to ...
2
votes
1
answer
123
views
How to bulk remove trivial if statements
I'm working on refactoring a big codebase and part of the refactor includes removing some checks. I couldn't figure out a way to do this efficiently. For example if the old code was something like:
...
0
votes
2
answers
90
views
How to refactor type-specific but almost same redundant operations without full class templating
I'm working on a C++ class that needs to perform type-specific operations on different data structures. For specific reasons, making class template parameterized is not a solution for me.
but I'm ...
0
votes
1
answer
422
views
How to simplify SwaggerUI code in Rust's Utoipa
I'm currently generating the Swagger docs HTTP error responses by adding them to each URI function like this:
#[utoipa::path(
context_path = "/user",
tag = "user",
...
0
votes
3
answers
134
views
How do I dplyr `summarize` and/or `mutate` over a list of parameter values, without an external `for` loop or generating extra columns?
I've been asked to generate something like this:
library("tidyverse")
df <- tibble(
comparison_var = c(1:10),
var_to_sum = runif(10, max = 10),
other_var = runif(10, max = 50)
)
...
0
votes
1
answer
55
views
Identify classes that could be replaced by one generic class?
Imagine a larger codebase. Is there any tool or functionality built-in in Rider or Visual Studio that can recognize classes that are similar except for maybe just different data types? So a ...
0
votes
1
answer
117
views
PostgreSQL: Making breaking changes in relational Database between app versions - how to rollback?
Assume that I am doing some refactoring in app's code that uses some relational database. It was decided that some columns and tables are not required from domain perspective, require renaming or have ...
0
votes
1
answer
98
views
How to use Laravel routes as fallback when physical file does not exist
I want to migrate a very old-fashioned PHP app gradually to Laravel. The application does not yet use a general entry point, but uses direct file URLs to work. So, in order to gradually move over ...
-1
votes
1
answer
283
views
Automatically add hierarchies in Verilog code
I have a working code generator, that on top-level, just instantiates modules and takes care of all the connectivty - that one is proven to be working.
I would like now to partition some of the ...
0
votes
0
answers
86
views
Combine results from API requests and aggregate totals
I have inherited a PHP project, it is written in Laravel 9.2.
There is a particular endpoint in the application that needs quite a bit of work. I'll post the code below.
It accepts a POST request with ...
1
vote
2
answers
82
views
How can I refactor similar functions to avoid code duplication in C?
I am working on a Tetris-like game in C and I have two functions, check_left_side_occupation and check_right_side_occupation, which are very similar. I want to refactor them to avoid code duplication, ...
-1
votes
1
answer
69
views
Correct approach to refactor duplicate API Call to different endpoints
I have two methods that make a call to two different endpoints. The logic is exactly the same, however the API Endpoints have to be kept seperate. How would you refactor this?
public List<...
1
vote
1
answer
83
views
Pythonic refactor advice needed
I am writing a tokenizer for files that have ignored preamble. The files are written in Markdown and there is a list of keywords in H1 titles that change the state of the parser. When an EOF is ...
0
votes
1
answer
757
views
How to plan migration from EF 6 with EDMX to EF Core
We have a pretty complex .EDMX in EF 6.0 which was designed using database-first approach (against SQL Server) back in 2014.
It uses lot of features of EF like TPT, TPC, TPH, entity splitting, custom ...
0
votes
1
answer
121
views
How to Remove Wildcard Imports from a Large Python Repository?
I am working on a large python project that contains many thousands of files, includes a mix of independent scripts (many with main functions) and common modules.
Unfortunately, in my project there is ...
0
votes
2
answers
75
views
IntelliJ refactoring: join two variables into once
I have this class
@Data
@NoArgsConstructor
public class DittaIndividualeDTO implements Dati {
private String denominazione;
private String nome;
private String cognome;
private String ...
-1
votes
1
answer
147
views
I want to add retry logic and. refactor the code in the python socket connect code
I have the below Python code which checks whether the ssh host is up or not:
`for hostname ,ipaddr in host_dict.items():
if tcp_conn.tcp_port_is_open(ipaddr, constants.TCP_PORT, ...
2
votes
2
answers
74
views
How to automate a series of similar IF statements
I have a series of IF statements that I think should be automated into a shorter piece of code but I'm not sure how to go about doing it. Here's an example of the code:
var supplier_kw_per_rack = 2;
...
0
votes
0
answers
66
views
Refactor multiple public classes in a folder/namespace to internal classes
Imagine 10 public classes in a folder/namespace. I want to make all of them internal. Any way to do this using Rider without modifying each file manually?
3
votes
3
answers
113
views
How to refactor similar functions in Python?
I have defined multiple functions where I search for a specific pydantic model in a list of pydantic models based on some attribute value.
SocketIOUserSessionID = str
RoomWithIndex = tuple[Room, ...
0
votes
0
answers
84
views
Refactor the method
I have a method that works with both a list and a single element. Is there a concise way to accept either of these types (perhaps using generics, etc)
public void write(MyInter elemen){
...
0
votes
1
answer
65
views
Refactor a function
I heve this function into two different component in React in order highlithe a value if it is equal to the one I am searching.
const generateHighlightedText = useMemo(() => {
const regex ...
0
votes
1
answer
154
views
Improving LSTM Model for Stock Trading and Speeding Up Code Execution
I have been working on a stock trading algorithm using an LSTM model. The algorithm fetches real-time data, makes predictions, and decides whether to buy or sell stocks based on the predicted price. ...
-1
votes
1
answer
45
views
return firts present Optional
I have a few validation cases which returns Optional.empty() or Optional.of(new Object())
How to return the first non empty result of this cases?
on this method I want to return the first not empty ...
0
votes
1
answer
65
views
Multiple if exists in PSQL function
I have code like that, I'm thinign if there is a better way to write it?
create or replace FUNCTION "catalog"."checkUsers"(userID integer)
RETURNS bool
AS $$
DECLARE
v1 ...
1
vote
0
answers
35
views
Copy/pasting a lot in Apache Flink jobs
This is more a code refactoring question and Im seeking suggestion on how best to improve code reusability.
I have jobs that do similar things. When I say "similar" I mean: all jobs stream ...