354 questions
-3
votes
1
answer
189
views
How to set primary constructor naming convention to CamelCase
When I refactor a class with a regular constructor to a primary constructor I'd like Visual Studio to capitalize the name of the parameters.
For example:
public class Desk
{
private Guid Material;
...
1
vote
1
answer
60
views
Automated refactoring of old-style get/set method pairs to true C# properties for entire solution
I have a legacy application with lots of cases where classes use an old-style (Java-like) property pattern with getXXX() and setXXX() method pairs and a backing private variable, for example:
class ...
-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
62
views
Automatically collapsing intermediate variables in a python function
I have many hundreds of python functions I'm evaluating for memory usage, and many of them differ simply by the usage of intermediate variable assignments. I would like a way, if possible, to ...
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 ...
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 ...
10
votes
1
answer
1k
views
Is there a way I can define a custom refactoring in Visual Studio Code?
It is possible to define custom snippets of code that VS Code can auto complete. These can even use place-holders so that one can fill in the blanks as required.
/* Before */
//=
/* After (for ...
18
votes
5
answers
22k
views
How to detect dead or unused code in Angular?
I and my team are working on an angular application from more than a year now. As part of our code refactoring process we want to delete unused or dead code from our repo.
Is there any technique or ...
1
vote
1
answer
201
views
Can I reproduce eslint's "prefer-object-spread" rule using ast-grep?
I am trying to compare different linters and their performance with custom rules. Ast-grep is promising, and likely runs much faster than eslint, as it is written in Rust instead of javascript. ...
5
votes
1
answer
2k
views
In VSC, how can I activate "refactor preview" when renaming a module in Python?
I wanted to rename a module in a Python project, however I would then need to update all the imports to match. The VSC Python extension has a clearly documented feature that should do this listed here:...
9
votes
3
answers
2k
views
How to automate Java code refactoring using a script with instructions?
How to refactor this class programmatically via Java code/Groovy plugin?
Let's say, I need to:
Rename foo.method2 to foo.method3
Rename myMethod to yourMethod
Change the imported package org.you.core....
4
votes
2
answers
6k
views
Code generation "Quick Actions" in Visual Studio 2022 no longer working in C#
Typically when I implement an interface or write code for which usings are missing it is possible to press Ctrl+. (or right click and press 'Quick Actions and Refactorings...') to get a menu of ...
10
votes
1
answer
23k
views
Python Black Code Formatter - Is there any way to apply automatic black formatting before commiting project to Github
Recently I started to use Black code formatter for my projects and sometimes it can be hard to track did I formatted all my changed files or not.
Let's assume that my project contains 20 different ...
2
votes
2
answers
230
views
Is there a generic way to make deep recursive functions work without changing system recursion limit?
We have a Python codebase containing quite a lot recursive functions, they may run into deep recursions and break the recursion limit with default Python interpreter settings. We have used sys....
10
votes
1
answer
15k
views
Is there an option to remove unused references on save in Visual Studio 2022?
Is there an option to remove and sort usings automatically on save for the current document? This used to be provided by the Power Commands for Visual Studio extension. Is this available somewhere in ...
3
votes
1
answer
827
views
Is it possible to replace "auto" with its deduced type, automatically, in C++?
I've got a project I've been wrestling with for a while, which is almost ready for submission; but there have been a few previous coders who have contributed. Their code is great, but it doesn't ...
4
votes
1
answer
6k
views
How to update YAML file without loss of comments and formatting / YAML automatic refactoring in Python
I would like to update YAML file values in Python without losing formatting and comments in Python. For example I would like to tranform
YAML file
value: 456 # nice value
to
value: 6 ...
13
votes
5
answers
9k
views
Python: Good way to get function and all dependencies in a single file? [closed]
I'm working on a big Python code base that grows and grows and grows. It's not a single application - more of a bunch of experiments that share some common code.
Every so often, I want to make a ...
6
votes
4
answers
2k
views
Automatically Update Python source code (imports)
We are refactoring our code base.
Old:
from a.b import foo_method
New:
from b.d import bar_method
Both methods (foo_method() and bar_method()) are the same. It just changed the name an the package.
...
0
votes
1
answer
242
views
Visual Studio Stop Refactoring Away Using In Specific Area
Usually, I can disable an annoying warning by wrapping two pragma warning disable statements around it. For instance:
#pragma warning disable IDE0060
public static int MultiplyByZero(int Number)
=&...
9
votes
1
answer
1k
views
Update namespace and imports of other files after moving class
Does anyone know if it's possible to configure VSCode to have the following occur after moving a file to another locations?
Update the namespace of the class/trait.
Update the imports of all other ...
4
votes
2
answers
793
views
Bulk rename of Java classes
Background
Hundreds of class files need to be renamed with a prefix. For example, rename these:
com.domain.project.Mary
com.domain.project.Jones
com.domain.project.package.Locket
com.domain.project....
0
votes
1
answer
104
views
Is there a preferred method to reorganise C header files in a project?
I have been given a medium-sized but complex C project (about 200,000 lines in total) which contains around 100 .h files and nearly as many .c files.
Many of the .h files correspond to equivalent .c ...
10
votes
1
answer
2k
views
Applying a Typescript refactoring programmatically
VS Code has a 'Convert namespace import to named imports' refactoring. As far as I understand, the refactoring is defined in the Typescript codebase itself, so it's not specific to VS Code.
I need to ...
1
vote
0
answers
353
views
Customize Refactoring for Python in Visual Studio Code
This is a small quality of life issue, but I'm curious if there is a solution.
I'm working with a python file in visual studio code. I'm using the "Extract Method" feature to do some ...
0
votes
3
answers
2k
views
REACT JS code, after SAVE (CTRL+S) change all the right syntax to a totally wrong syntax. VSCODE
BEFORE SAVE
AFTER
this thing has never happened to me with languages like c++, etc...
in other cases it happens but for the better, for example my html code becomes more orderly and clean.
the ...
1
vote
1
answer
497
views
How to read a line from text file (file containing logs) and remove timestamp IF it's there?
I am writing an automated code that opens a text file and reads it line by line:
if __name__ == '__main__':
#Argument Required: Full directory of log file for processing
parser = ...
1
vote
1
answer
1k
views
VS Code refactoring in JS doesn't seem to work in unopened files
When trying to refactor function names, variable names, or class names within all files using F2 (as shown at https://code.visualstudio.com/docs/editor/refactoring#_rename-symbol), I only seem to have ...
0
votes
3
answers
533
views
Regular expression to identify a python function body and locate all the executable lines (ie non-comments)
I have a file that is a python code (may not be syntactically correct).
It has some functions which are commented out except the signature.
My goal is to detect those empty functions using a regex and ...
0
votes
1
answer
104
views
How generate scriptfu scheme code in GIMP?
Gimp has script-fu for scripting code in Scheme. But i don't know does ít has the reverse function? It mean, when i draw or do something, can it generate scheme code or any language parallel with that ...
0
votes
0
answers
44
views
Refactor all getters / setters not to start with a leading get / set across entire Java codebase
I'm looking for a suggestion on how to refactor a +50K lines of Java.
Inspired by version 2.x of the AWS SDK for Java, which has many builders and almost no getters / setters that start with a leading ...
23
votes
12
answers
2k
views
Java source refactoring of 7000 references
I need to change the signature of a method used all over the codebase.
Specifically, the method void log(String) will take two additional arguments (Class c, String methodName), which need to be ...
1
vote
1
answer
171
views
C++ function called in multiple places, how to refactor to accept a new argument?
I have this function f(MyType a, b) and I want to it to become f(MyType a, b, c). The problem is that f is called by multiple other functions (g(), h(), i()) which in turn are called by multiple other ...
0
votes
1
answer
385
views
VS 2019 - quick action menu items missing
I have two Win10 PC, both with the same installation VS2019 Enterpsrise(Version 16.11.15). Almost the same extensions. But in one VS installation, quick action menu and it's options look like on the ...
13
votes
3
answers
18k
views
Python refactoring fails in Visual Studio Code
I switched to Visual Studio Code for Python programming recently. Below is my Python configuration in Visual Studio Code settings:
"python.pythonPath": "/Users/hzhang/.virtualenvs/env-2.7/bin/python",...
8
votes
8
answers
10k
views
Refactor foreach to for loop
I have a foreach loop in Java (simplified version here)
List<String> names = getNames();
for(String name:names) {
doSomething(name);
}
Is there an automated way to refactor this to a ...
34
votes
6
answers
14k
views
How to refactor a static inner class to a top level class in Eclipse?
I am having trouble finding the correct refactor option for the following scenario:
I have code like this (in Outer.java):
public class Outer {
// ... class stuff
public static class Inner ...
0
votes
0
answers
134
views
WebStorm - Object structure refactoring
In WebStorm, I would really like to know if there's a way to refactor the structure of objects.
Let's say I have this object,
inventory = {
fruits: [
{type: 'apple', quantity: 24},
{type: '...
5
votes
2
answers
2k
views
Apply Visual Studio Quick Actions and Refactorings across entire C# solution
I am trying to cleanup/refactor a legacy C# solution and am therefore exploring options how certain refactorings or quick actions could be applied for the entire solution.
For example, Visual Studio ...
2
votes
1
answer
261
views
Automatic replacement of indirect imports
I have a small module that defines a function:
# small_file.py
def func():
...
I have a larger module that does a wildcard import of that one:
# giant_file.py
from small_file import *
...
I have ...
11
votes
2
answers
1k
views
TypeScript Compiler API loses formatting during transformation
I have to modify around 1 000 of typescript files in a specific way: I need to replace all StringLiteral and JsxText tokens with a CallExpression to a translation function for internationalization ...
3
votes
4
answers
4k
views
Auto remove getter-setters with lombok?
I have a project. I don't use Lombok. I use manually created getters and setters.
Now, I want to import Lombok. After I import, I will use for all entities.
Do I have to manually add @Data to all ...
16
votes
3
answers
30k
views
Getting clang-tidy to fix header files
I'm in the process of moving a project currently compiling with gcc to clang,
and have a bunch of warnings that gcc didn't generate (-Winconsistent-missing-override). clang-tidy works for fixing these ...
6
votes
2
answers
2k
views
Intellij IDEA extract constant through entire project
Let's say I have a "magic string" in four classes and I want it to be replaced in all places by one constant from some constants class. (I'm speaking about Java/Groovy classes but any other languages ...
46
votes
1
answer
8k
views
Eclipse : transform static method invocation to a static import
Is there a way to transform automatically this static method invocation (Arrays.asList):
import java.util.Arrays;
import java.util.List;
public class StaticImport {
public static void main(...
0
votes
1
answer
320
views
After refactoring function inside closure is unused
I was extracting closure to method but I always get this error:
Function is unused
This is whole working func:
fileprivate func attemptToChangePassword() {
passwordChanger.change(...
0
votes
1
answer
505
views
How to safe delete the usages of struct field on all files from Intellij?
Though we have refactoring tool to rename the struct field we do not have refactoring tool for deleting the struct field & its usages.
How to safely delete the struct field and its usages[Write &...
27
votes
2
answers
11k
views
Automated refactoring to add parameter names to method calls
I am in the middle of a big refactoring.
I have dozens of methods, which are called via positional parameters. Now I would like to have them called via named parameters. The methods exist in several, ...
5
votes
1
answer
615
views
Reorganize large TypeScript project from the command line
I have a medium/large TypeScript project (~500 source files) and I'd like to do a large-scale reorganization, changing the directory structure and moving all the modules around.
It's easy to move a ...
2
votes
1
answer
481
views
Clang format breaks separation of big numbers with apostrophes
In c++14 we can use ' to write big numbers in a more readable way, like this: 2'000'000'000'000'000'000. But my clang-format turns it into this: 2 '000' 000 '000' 000 '000' 000. What should I do to ...