Is Rubocop Method Name Length Configurable? - ruby

I know a number of the other Metrics are configurable in the .rubocop.yaml file, but I haven't found anything for this. Does anyone know if this is possible?

There is no existing cop for method name length, but it would be possible to write one:
https://github.com/rubocop-hq/rubocop/blob/master/manual/development.md

Related

NIFI:Merging Flowfiles by filename in MergeContent processor

I have flowfiles named as (1,3,4,5 and etc) i use this ${filename} attribute for invoking online service, then i got big response and split it line by line but at the end i need to merge my flowfiles based on their name i think mergecontent doesn't work prperly i use Correlation atribute name -filename and i have also increased minimum and maximum number of entries but nothing helped me here is my workflow:
also there is several subject i am interested in:
I think that main reason my mergecontent doesn't work properly is that my file names don't go one after another , can this bean real reason?
Can you reccomend me any better solution for such task?
Simple trick, you should be using filename as its asking for correlation attribute name instead of ${filename}
PS: i guess this answer is 2years late, well you never know whom it will help :P

FHIR DataRequirement metadata type

I am implementing a CDS system, and I would like to use the DataRequirement type to ask for additional information. However, I am having some difficulties to understand the filter elements ("codeFilter" and "dateFilter").
For example, the property "path" of the filter elements is of string type, but what is the format to specify this path?
I have been searching some examples from the FHIR specification, and I've tried to follow the "path" in the resource object. I attach below an image with an example and the specification of the resource "MedicationRequest" that is being addressed in this example. Can anyone explain me over this example how to traverse throw the elements? What is the element "code" from the path refering to?
example DataRequirement.codeFilter
Can anyone help me with this issue? Examples of use would be appreciated!
Thanks in advance.
It's referring to the FHIRpath query - see spec.
The path element is a FHIRPath, but for simplicity, it assumes the ability to traverse references. Without that, the dereference would have to be explicit, as in:
medicationReference.resolve().code
The spec isn't clear on this, so I will submit a tracker to add that clarification.

How do I add letters prefix before my order number?

all Im trying to add a few letters before the order number in magento, currently they are at default 100000001, 100000002, etc but I'm wanting something like,TD10000001, TD10000002, I've checked out several tutorials that say I need to edit the: Mage_Eav_Model_Entity_Increment_Numeric function but there doesn't seem to be a decent tutorial telling me how to do this.
Any help would be appreciated.
Answered, found an awesome free plugin by MSWebDesign that allows prefixes before the order number exactly what I wanted, hope this helps anyone else.

How to detect if an element exists in Watir

I'm relatively new to Watir but can find no good documentation (examples) regarding how to check if an element exists. There are the API specs, of course, but these make precious little sense to me if I don't find an example.
I've tried both combinations but nothing seems to work...
if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists
then...
if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists?
then...
If anyone has a concrete suggestion as per how to implement this, please help! Thanks!
It seems you are missing a comma between parameters.
Should be
if browser.image(:src, "/media/images/icons/reviewertools/editreview.jpg").exists?
Also you can find this page useful in future to know what attributes are supported.
The code you posted should work just fine.
Edit: Oops, wrong. As Katmoon pointed out, there is a missing comma.
browser.image(:src "/media/images/icons/reviewertools/editreview.jpg").exists?
One problem you may get caught up in is if the browser variable you specified is actually an element that doesn't exist.
e.g.
b = Watir::IE.start(ipAddress)
b.frame(:name, "doesntExist).image(:src "/media/images/icons/reviewertools/editreview.jpg").exists?
The above code will throw a Watir::UnknownFrameException. You can get around this by first verifying the frame exists or by surrounding the code in a begin/rescue block.
Seems like you are using it correctly. Here is an old RDoc of Watir.
Does it not work because Watir cannot find it? Hard to tell because there is no source or link to the page that is being tested. I think that I only use image.exists?. In general, errors that come from when the image exists but is not found are:
The how is not compatible with the element type. There is a cheatsheet to help you see which object types can be found with different attributes here.
The what is not correct. You may have to play with that a little bit. Consider trying a regex string to match it such as browser.image(:src, /editreview.jpg/). As a last resort, maybe use element_by_xpath, but there are maintenance costs with that.
The location is not correct. Maybe the element is in a frame or something like that. browser.frame("detail").image(:src, /editreview.jpg/).
Try those, but please let me know what worked. One more thing, what are you checking for? If it's part of the test criteria, you can handle it that way. If you need to click on it, then forget the .exists? and just click on it. Ruby will let you know if it's not there. If you need it to be grace, learn about begin/rescue.
Good luck,
Dave

Detecting misspelled words

I have a list of airport names and my users have the possibility to enter one airport name to select it for futher processing.
How would you handle misspelled names and present a list of suggestions?
Look up Levenshtein distances to match a correct name against a given user input.
http://norvig.com/spell-correct.html
does something like levenshtein but, because he doesnt go all the way, its more efficient
Employ spell check in your code. The list of words should contain only correct spellings of airports.
This is not a great way to do this. You should either go for a control that provides auto complete option or a drop down as someone else suggested.
Use AJAX if your technology supports.
I know its not what you asked, but if this is an application where getting the right airport is important (e.g. booking tickets) then you might want to have a confirmation stage to make sure you have the right one. There have been cases of people getting tickets for the wrong Sydney, for instance.
It may be better to let the user select from the list of airport names instead of letting them type in their own. No mistakes can be made that way.
While it won't help right away, you could keep track of typos, and see which name they finally enter when a correct name is entered. That way you can track most common typos, and offer the best options.
Adding to Kevin's suggestion, it might be a best of both worlds if you use an input box with javascript autocomplete. such as jquery autocomplete
edit: danish beat me :(
There may be an existing spell-check library you can use. The code to do this sort of thing well is non-trivial. If you do want to write this yourself, you might want to look at dictionary trie's.
One method that may work is to just generate a huge list of possible error words and their corrections (here's an implementation in Python), which you could cache for greater performance.

Resources