We use Code Analysis within a build server with the firm restriction that we cannot commit code if a Code Analysis rule breaks. CA1822 is enabled and therefore we have many, many static functions. Now we want to force unit tests with mocking and dependency injection. But with our many static functions it is not easy to mock some static function. Especially when a static function calls a static function. I'm thinking about disabling CA1822 to reduce the static functions because I'm aksing myself: Is CA1822 obsolete for development with a mocking fw and code injection? I read in many other questions, that performance is not the matter. So what for making a function static? In my opinion CA1822 lead to a bad design. Am I wrong?
Leads CA1822 to a bad design for modern development when it comes to unit testing?
506 Views Asked by Jeremy Benks At
1
There are 1 best solutions below
Related Questions in UNIT-TESTING
- Google Truth.assertThat.contains does not behave similar to List.contains
- What's the best way to breakup a large test in pytest
- How to refer to the filepath of test data in test sourcecode?
- How to mock a dynamic endpoint in Apache Camel Spring Boot
- pytest mock failing when mocking function from imported package
- Jest configuration error while running test case in teamcity
- Resolve paths dynamically based on directory where test (or tested files) is located in Jest
- One-time implementation with Jest's mockResolvedValueOnce within test remains from one test to another
- Why can't I mock the decorator of the function?
- Gitlab pipeline stuck with nx cloud issue
- How to create an improperly closed gzip file using python?
- Nest.js service structure for API integration
- uiState not updating in Tests
- Unit Tests not Compiling or Being found without mod tests in main.rs. Is this a requirement or am I missing some configuration?
- Mocking Stream or Reader in Java Junit
Related Questions in MOCKING
- How to mock a dynamic endpoint in Apache Camel Spring Boot
- pytest mock failing when mocking function from imported package
- Do we need IoC containers in typescript if ts-mock-imports exists
- how to mock default_factory in pydantic model
- Mocking Stream or Reader in Java Junit
- Spring Boot, Tests: Mock inside nested functions
- How to mock a no response from server with Gin Golang
- Pytest PropertyMock not returning different attribute values
- Cannot perform http mock while integration testing flutter
- NestJS: HttpService is not mocked or found within unit-test
- Catching a signature of celery task in pytest
- How to mock a Python function so that it won't be called during import?
- What is the equivalent of sinonStub.callsArg(2).returns({}) in Jest?
- How to mock a function in multiple modules
- How to mock class with param, return this class. As when(new A(any(B.class))).thenReturn(any(A.class));
Related Questions in CODE-ANALYSIS
- Are there any way to export Sonarlint report from Intellij?
- generate incoming call graph
- Find line of text in MsgBox with a string literal with VBA regex
- Don't resolve typedefs in Visual Studio 2022 tooltips
- Disable "Code analysis" in Visual Studio Code with C++
- error CS1056: Unexpected character '$' during code analysis
- Generate a 'readonly record struct' using Roslyn
- How can I see debug info about the VS Code Cpptools extension's IntelliSense and Code Analysis?
- dotnet Code Analysis ignoring certain entries in .editorconfig file
- How can you distinguish between a standard library call, a third-party library call, and an API call from the repository?
- Clarification needed: core differences between two receipt selection code snippets
- Async method's return decorated with "NotNullIfNotNull" still returns variable that may be null
- Why is Visual Studio saying this cast from System.Int32 to System.Byte is redundant?
- Generic not-null validator for CA1062 in .NET 6
- How do code analysis, AST generation and SARIF report work in MSBuild?
Related Questions in CODE-INJECTION
- How can I disable JVM bytecode verification at runtime?
- Component inheritance and sharing of elements in Angular with dynamic template
- VSCode Extension - Grammar Injection Into Multiple Languages
- Toastr implementation in Angular17 at standalone components
- Inject own Logic into existing Quakus Extension
- Cannot wait until the entire DOM is loaded with Scripty Chrome extension
- .NET MAUI 8: System.Reflection.TargetInvocationException on initializing the main view with dependency injection
- SegmentationFault of sprintf in CSAPP Attack Lab
- Checkmarx vulnerability - if embeds untrusted data
- chrome extension to inject javascripts (one or more) on a webpage
- Determining the end of output and readiness for input of the сonsole process in C#
- Possible Injection Risk on Azure Synapse Spark when using certain key words in strings in where or join clauses
- Issue with CreateRemoteThread causing target process crash
- Injecting JS to script tag inside HTML
- JavaEE - Strategy Pattern - Error while injecting Lambda
Related Questions in TESTDRIVENDESIGN
- Using Test-Driven in DDD (Domain layer)
- Repository pattern for database that allows CRUD operations through Interops
- TDD principle, how to make the test fail
- Some confusion about test driven development
- Java program to prove Test Driven Development
- Unit test contains instances of other classes not only mocks
- Unit testing vs TDD(test driven dev) What is the difference?
- Where to start with test driven development?
- Leads CA1822 to a bad design for modern development when it comes to unit testing?
- How can I test exceptions using Test Driven Design concept in eclipse
- TDD CRUD based scenario
- TDD multi threaded applications
- Why extract an interface when we can DI a delegate to make it testable?
- TDD and MVC Crossroads. What ORM integrates nicely?
- Unit Testing or Functional Testing?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
CA1801 is the ReviewUnusedParameters rule. CA1822 is MarkMembersAsStatic, which is the one that I'm guessing is actually causing problems for you.
The good news is that neither of these rules fires for an implementation of an interface method, so you should have no problems with either rule if you start decoupling via interfaces in order to enable inversion of control and mock substitution for unit testing.