Need to Create Ncover Report That does not Include private methods and properties in the Coverage - ncover

I an Creating Ncover report but in the report all the private methods and properties are also listed and they affect the coverage as well so is there any way to hide them.
thanks
priya

NCover cannot distinguish between private methods, properties, and classes and other kinds of code. So, the only way to exclude private methods is to create pre-coverage filters that exclude them specifically by name
The help doc shows how to set up pre-coverage filters on the Settings tab of an NCover 4 project:
You will decide what to exclude based on your own knowledge of the source code, but a filter to exclude a method will look something like the example below:
"Exclude","Module","Matches","Algorithms.dll"
A filter to exclude a class will look something like the example below:
"Exclude","Class","Contains","SwapSorter"

Related

log is not accessible in normal groovy file of grails3

Migrated grails2 to grails3.
In grails2 i used lots of
log.info,log.debug
statements in side src/main/groovy files.
but in grails-3 by default log is not injected.
it's giving error like No such property: log for class
This is a planned change. You can use #groovy.util.logging.Commons annotations on your non-grails classes to have log available. Also other like #Log4j, #Slf4j are available, depending on your logging library.
There is one more difference which is important - those annotations will add log as private property and classes which will inherit from them, will also need to be annotated to use logging. Alternative is to manually define protected logger on your class.

Grails: Turn off Codenarc NoDef rule for controller actions

Is there a way to turn off the Codenarc NoDef rule for Grails controller actions? The rule is a good practice to follow in general but since some actions return a value and some don't, we typically use def to support all variants. I looked around a bit to see if this rule can be turned off for controller actions but came up empty. Does anyone know?
You can't exclude specifically Controller actions and you can't exclude by class name either (using the doNotApplyToClassNames property) because the rule is applied by file level and not class.
The closest I could get was to exclude the whole Controller from the rule like this:
NoDef.doNotApplyToFilesMatching = /.*Controller.groovy/
I also recommend excluding Services and grailsApplication injection from the rule, as it doesn't bother me to have defs there. For example:
class SomeService {
def otherService
def grailsApplication
}
The rule configuration for this should be:
NoDef.excludeRegex = /(.+Service|.+Controller|grailsApplication)/
I read the blog post and tried the doNotApplyToClassNames option, but it didn't work.
From the documentation:
NoDef Rule
Since CodeNarc 0.22
NOTE: This rule applies to the text contents of a file rather than a
specific class, so it does not support the applyToClassNames and
doNotApplyToClassNames configuration properties.
So you cant actually use the doNotApplyToClassNames parameter, but there is a excludeRegex property that you can use, but you would need to come up with a regular expression to exclude your controller actions.
Regular expression describing names of attributes, parameters or
methods that could be precede by the def keyword.
If you are using codenarc plugin then I believe you should be able to disable some of the rules in codenarc rule set file as mentioned in this blog
http://www.tothenew.com/blog/grails-clean-code-configure-codenarc-plugin/

How to define style resources for specific control in Xamarin.Forms?

I am newbie to Xamarin and Xamarin.Form, basically I want to define style for the controls.
Like when I place Label control then it should follow the same style throughout the page. I've read somewhere on article that it can be done by defining styles in tags but don't know how..
How to define for 1 page
How to define globally which will be applied to all the pages
How to define device specific
Can anyone provide some example code / link for same?
Thanks in advance!
If you are talking about doing it through XAML then:
- if it is per page then go with resources.
- for device specific, use OnPlatform class
- there are no global resources currently
If you are creating your stuff in code then apply whatever global value you wish when you create them. If there are platform specific values then use Device class.
HTH
For per page resources, you can create a Common folder with files such as "ColorResources" which might have entries such as
public static readonly Color ActivityIndicator = Color.Blue;
You can then use that in your XAML like this
<ActivityIndicator IsRunning="{Binding IsLoading}"
Color="{x:Static common:ColorResources.ActivityIndicator}" />
(Remember to declare your common namespace)
For cross page, I'd recommend a custom renderer, built from the original control but tailored to look like what you want. You can find out more hereCustom Renderers

Grails Logging - Exclude One Class

I have a project consisting of hundreds of various classes. One of these extends a class located in a JAR library and produces tons of log info. I would like to exclude this one class from producing all this logging information.
Here's my config.groovy logging section:
trace('grails.plugin.springsecurity.web.filter.DebugFilter',
'grails.app.conf.com.myrootpackage',
'grails.app.controllers.com.myrootpackage',
'grails.app.domain.com.myrootpackage',
'grails.app.filters.com.myrootpackage',
'grails.app.services.com.myrootpackage',
'grails.app.taglib.com.myrootpackage',
'com.myrootpackage')
Since all of my classes are located in the com.myrootpackage package or sub packages of that, I'm not sure how to exclude the one class. As far as I can tell, the logging setup in config.groovy only allows specifying the beginning of class names so I would have to specify by name all other classes and omit the one I want to omit, or move the one I want to omit to a separate root package. Both of these seem silly to have to do to just omit one class from producing log output.
As far as I can tell, the logging setup in config.groovy only allows specifying the beginning of class names
No, you can use the full class name to configure an individual class, so the following should work
trace('grails.plugin.springsecurity.web.filter.DebugFilter',
'grails.app.conf.com.myrootpackage',
'grails.app.controllers.com.myrootpackage',
'grails.app.domain.com.myrootpackage',
'grails.app.filters.com.myrootpackage',
'grails.app.services.com.myrootpackage',
'grails.app.taglib.com.myrootpackage',
'com.myrootpackage')
error 'com.myrootpackage.ExcludeMe'
I've assumed
com.myrootpackage.ExcludeMe is the fully-qualified name of the class in question
this class should log at the error level instead of trace

Injecting code into generated xText classes

A rule in xText called "Component" will typically generate a class "Component" in the src-gen folder.
I would like to add additional methods to these classes without them being overridden every time I make minor changes to the DSL. What's the proper way to inject my own code into these classes and is there a way to make all classes extend my own root class instead of the default EObject?
Thanks in advance.
You basically have two choices:
You can use a IXtext2EcorePostProcessor to modify the EMF-model which Xtext inferred from your grammar. The actual code generation is done by EMF, so you have to fiddle your code through that bottleneck. The details are described in a blog of Christian Dietrich. This approach is only suitable for small modifications.
You can use the "generation gap pattern" (a.k. "implementation gap pattern") which allows you the write classes which derive from the generated model classes. Here you can add anything you want. The details are described in a blog of Heiko Behrens. This approach is better suited for large scale modifcations by inheritance.
You may of course mix the two approaches...

Resources