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 ...
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 ...
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 ...
-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 ...
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. ...
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....
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)
=&...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
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....
-2
votes
1
answer
38
views
Is there a regex or other tool I can use to change a method call to a function call that encloses the previous expression?
I'm working on making a change to a large C++ codebase where I need to change a method call to an equivalent function call, e.g. someExpression.foo() becomes bar(someExpression).
A few more examples ...
-1
votes
1
answer
48
views
How do i reformat java comments, to remove whitespaces in intellij?
What IntelliJ format setting should be set to automatically change line comments to look like:
validcode();
// comment1
// comment2
validCode();
from lookin like this:
validcode();...
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: '...
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 = ...
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 ...
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 ...
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 ...
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 ...
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:...
1
vote
0
answers
49
views
How to help PyCharm discover tests after refactoring
Summary: After moving a file with a TestCase class in it (using refactor), tests are no longer executed at all.
I have a class startupTests.py that has:
import unittest
import logging
logging....
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
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(...
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 ...
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 ...
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 ...
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 ...
1
vote
0
answers
116
views
Automating refactoring for redundant Delphi code?
I wrote this redundant code consisting of 30 lines:
if Button = TMouseButton.mbLeft then
begin
if pnlEndColor.ShowCaption then
begin
pnlStartColor.ShowCaption := False;
pnlEndColor....
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.
...
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
votes
1
answer
89
views
Smart search and replace [closed]
I had some code that had a few thousands lines of code that contain pieces like this
opencanmanager.GetObjectDict()->ReadDataFrom(0x1234, 1).toInt()
that I needed to convert to some other library ...
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 ...
0
votes
1
answer
40
views
What can i doing here to detect the duplicate in the two methods
Two methods intValueOf and intValueOfOptional, which are very similar.
I would like to modify the implementation so that the two methods use as little duplicated code.
Both methods contain a very ...
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 &...
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 ...
0
votes
1
answer
146
views
Rails: How can i refactor my controller params code
I need to refactor this private method. Codeclimate is giving me a error msj because the line of the params is too long. How can i refactor it?
def base_plan_params
params[:base_plan][:...
2
votes
1
answer
231
views
change templates for new members
when I do refactoring in visual studio (2019) and I say "generate field", it per default always adds the "private" keyword before the new field. I don't want this. How can I modify ...
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 ...
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 ...
0
votes
1
answer
486
views
Libclang: Get Symbol (e.g. function) at SourceLocation
I want to write a refactor tool, where I want to move the function at the cursor(cursor is in the function name) to the source file.
I found the FunctionMover.cc in https://github.com/lanl/CoARCT ...
0
votes
2
answers
388
views
How to automate Methods mapping between two java classes?
I have a legacy springMvc project and i want to refactor all the controllers to return ResponseEntity object rather then returning Model object which is returned by default.
I am looking for a way ...
0
votes
1
answer
238
views
Is there any alternative to handle multiple if , if else based on Element presences using selenium
I was working in automating e2e automation cases.To increase the reusability we have used many if conditions inside a function and eventually script performance went down. Could anyone suggest me a ...
1
vote
1
answer
502
views
Removing noexcept from a C++ function, how to deal with the noexcept functions that call it?
Suppose I have a foo function marked as noexcept somewhere in my code. Many other functions call foo, and many of them are also marked as noexcept.
Now suppose I have to adjust foo, and now it can ...
0
votes
0
answers
71
views
Unable to locate a button Selenium Webdriver
I need to click on CC to verify if its working.Can't figure out, It gives me error.
public void cc() {
driver.findElement(By.cssSelector("button[class*='vjs-subs-caps-button']"));
}
...