ReSharper chop if long not working - resharper

I have the following code that when I run autoformat in ReSharper doesn't not get changed.
I thought Chop if long would cause a chop to occur if the right margin is exceeded.
If I turn on Chop always I get this.
This works, but I would rather not chop short statements like the first, which is what I assume Chop if long means.
Ideas?
Here are my ReSharper settings.
Turning on wrap long lines makes things even worse.
UPDATE1:
Here is the email I sent to JetBrains support.
The believe the central issues I'm facing is I understand the "chop always" setting, but I do not understand "chop if long" or "simple wrap". I have not found any documentation on what these settings mean, so I'm going off what I believe should be happening.
I am setting the "Wrap object collection and initializer".
Chop Always:
cdata.GetByIdData = new Category {
Id = "123",
Name = "category"
};
vdata.GetByIdData = new Vendor {
Id = "456",
Name = "vendor"
};
adata.GetByIdData.Add(new Account {
Id = "789",
Name = "account",
Balance = 5000
});
svc.ExecuteRequest(new AccountTransactionService.Add {
Kind = AccountTransaction.KIND_DEBIT,
Source = "789",
Destination = "dst",
Date = new DateTime(2011, 1, 1),
Categories = new List<AccountTransactionService.CreateCategory> {
new AccountTransactionService.CreateCategory {
Id = "123",
Amount = 200.50m
}
}
});
Chop If Long:
cdata.GetByIdData = new Category { Id = "123", Name = "category" };
vdata.GetByIdData = new Vendor { Id = "456", Name = "vendor" };
adata.GetByIdData.Add(new Account { Id = "789", Name = "account", Balance = 5000 });
svc.ExecuteRequest(new AccountTransactionService.Add { Kind = AccountTransaction.KIND_DEBIT, Source = "789", Destination = "dst", Date = new DateTime(2011, 1, 1), Categories = new List<AccountTransactionService.CreateCategory> { new AccountTransactionService.CreateCategory { Id = "123", Amount = 200.50m } } });
I would expect Chop If Long to look like this given a margin of 80:
cdata.GetByIdData = new Category { Id = "123", Name = "category" };
vdata.GetByIdData = new Vendor { Id = "456", Name = "vendor" };
adata.GetByIdData.Add(new Account { Id = "789", Name = "account", Balance = 5000 });
svc.ExecuteRequest(new AccountTransactionService.Add {
Kind = AccountTransaction.KIND_DEBIT,
Source = "789",
Destination = "dst",
Date = new DateTime(2011, 1, 1),
Categories = new List<AccountTransactionService.CreateCategory> {
new AccountTransactionService.CreateCategory {
Id = "123",
Amount = 200.50m
}
}
});

"Chop if long" works only when you turn on "Wrap long lines" option, so you should turn it on. I guess that http://youtrack.jetbrains.com/issue/RSRP-291146 prevented you from getting the formatting you wanted with "Wrap long lines" turned on. Well, it should be fixed in ReSharper 7.1 EAP - try and write us if you still have problems.

Change "Wrap object collection and initialisers" to "Simple Wrap", that should style your code in the way you want it to.
Unfortunately, I can't look up what Chop if long is supposed to do as the Resharper community site is blocked from work for some strange reason.

There is an issue logged with JetBrains that is depicting the same behavior you describe...
http://youtrack.jetbrains.com/issue/RSRP-291146

Related

Remove duplicates from output

I have the following output:
output "regions_data" {
value = regions({
for region, data in var.regions :
regions => "${region}/${data.postcode}"
})
}
Which contains duplicates like(it is intentional):
regions = {
reg1 = {
postcode = "1"
},
reg1 = {
postcode = "1"
},
reg2 = {
postcode = "2"
}
}
How can I remove the duplicates from the output?
Your code does not comply to the basic rules of maps or objects. Nor there is any regions function you use in the code. The provided code is not a proper Terraform syntax.
I believe however, you might have meant the following example:
variable "regions" {
default = {
reg1 = [
{
postcode = 1
area = "oak-county"
},
{
postcode = 2
area = "birch-county"
}
],
reg2 = [
{
postcode = 1
area = "fir-county"
},
{
postcode = 2
area = "pine-county"
}
],
}
}
In a case, when the two maps have the same keys, you can use flatten to break up everything to pieces, then rejoin everything back together:
locals {
flatten = flatten([
for region_key, region in var.regions : [
for area in region :
{
key = "${region_key}-${area.postcode}"
value = area.area
}
]
])
}
output "flattened_regions" {
value = local.flatten
}
output "remap" {
value = { for key, data in local.flatten :
data.key => data.value
}
}
Even if the code above doesn't exactly fit your case, please experiment in a similar manner - or, provide more complete example of variables you have and the outcome you need.
Source: https://www.terraform.io/language/functions/flatten
Probably what you want
I have no idea what you've meant by regions in value = regions({ but I assume that this code will do what you want:
locals {
regions = {
reg1 = {
postcode = "1"
},
reg1 = {
postcode = "1"
},
reg2 = {
postcode = "2"
}
}
}
output "regions_data" {
value = {
for region, data in local.regions :
region => "${region}/${data.postcode}"
}
}
Keep in mind that I replaced var with local to have one file.
And output of such is:
regions_data = {
"reg1" = "reg1/1"
"reg2" = "reg2/2"
}
Thought be warned that it will use one of keys. It doesn't check for duplicates. It just takes first one.
But why you shouldn't want it
This solution is quite bad for multiple reasons:
You provide variables - why the heck would you put duplicates? :)
As I said this merge will not necessarily provide the output you what
If var is provided by some terraform code (e.g. this regions_data is in module) then logic of merging should be done outside of module and probably terraform's own merge would be the answer.

How do i get a randomly selected string name and still select an existing substring without the code coming out as text

I'm currently trying to get info off of an object but that's randomly selected. I believe that the true problem is that what I wrote is not being taken as a variable for selecting an existing object if not as the variable for the object, I don't know if this is a clear message or not.
Example of what I have tried:
let PK = ["Random1", "Random2", "Random3"]
let PKS = Math.floor(Math.random() * PK.length)
let Random1 = {
name: "Random1",
number: "010"
}
let Random2 = {
name: "Random2",
number: "011"
}
if(message.content.toLowerCase() == "random"){
message.channel.send(PK[PKS].number)
}
There is another thing I have tried which is by using ${}. These are the results:
"Random1.number" or "Random2.number" when what I was looking for is actually "010" or "011".
You should wrap your objects inside some collection such as an Array and then you just compare the value from your random selection to the value find in the collection (if any (randoms)):
let PK = ["Random1", "Random2", "Random3"];
let PKS = Math.floor(Math.random() * PK.length);
const randoms = [
{
name: "Random1",
number: "010",
},
{
name: "Random2",
number: "011",
},
];
if (message.content.toLowerCase() == "random") {
const findRandom = randoms.find((v) => v.name === PK[PKS]);
if (findRandom) {
message.channel.send(findRandom.number);
}
}

How To Fill addressInfos object in self.Self object

I am trying to get the user's set home address from their profile. When testing on device, am consistently seeing it empty when it is set in the profile.
Here is the action used to extract the information:
action (ReturnSelfAddress) {
type (Constructor)
description (Gets address from profile)
collect {
input (mySelf) {
min (Required)
type (self.Self)
}
}
output (geo.SearchTerm)
}
This goes along with a javascript file that extracts the home address from the self.addressInfos field.
Here is a screenshot of my profile on the device:
And another of the address.
In testing I was using a real address.
The resulting self object I got from the profile was:
{
addressInfos = [],
birthdayInfo = {
calculatedFromNow = null,
day = 1,
fuzzyFactor = null,
holiday = null,
month = 1,
namedDate = null,
parseTree = null,
year = 1911,
$id = null,
$type = viv.contact.BirthdayInfo
},
contactId = null,
emailInfos = [{
address = fake#fake.com,
emailType = Home,
$id = null,
$type = viv.contact.EmailInfo
}],
isFavorite = null,
nameInfo = {
firstName = Bill,
initial = null,
lastName = Faker,
middleName = null,
nickName = ,
prefix = null,
structuredName = Bill Faker,
suffix = null,
$id = null,
$type = viv.contact.NameInfo
},
phoneInfos = [],
photoInfo = {
caption = null,
dimensions = null,
rotation = null,
size = null,
subtitle = null,
title = null,
url = http://image.to.be.put/here,
$id=null, $type=viv.contact.PhotoInfo
},
relationshipInfos=[],
workInfo=null,
$id=null,
$type=viv.self.Self
}
As you can see the addressInfos array is empty. How should I access the user's profile addresses?
EDIT:
The personal information here is dummy data I made up so I wouldn't have to share my actual email, birthday, phone number etc... When actually testing this on my device, all of this information matches my real developer account.
viv.self.Self is linked to Samsung account.
On device, Settings -> Upper right corner, you will be able to edit your Samsung account.
I've just added a work address, and able to access it using the following JS code.
module.exports.function = function displayProfile (self) {
console.log(self)
if (self)
return 'lable = ' + self.addressInfos[0].label + ' address = ' + self.addressInfos[0].address.unstructuredAddress;
else
return 'Not self';
}
Current IDE is able to fetch these info from your Samsung account, so you can test without on-device testing. Of course, I've also tested on device after private submission, and it works fine.
Please double-check that you have an address filled out in your Samsung account:
https://www.samsung.com/us/support/account/info/

using structFindKey and its path to add a new node with coldfusion

I am attempting to use structFindKey to create an "org" struct from a query.
I am starting with a query that looks like this.
from this I am trying to build a struct that represents the actual org structure that I would like to look something like this:
I am starting with my request.hierarchyStruct that looks like this:
here is the code so far
for(row in getCorpUserHierarchy){
insertIntoHierachy(row);
}
function insertIntoHierachy(thisRow){
var thisKey = thisRow.parentGroupId;
var newChild = {
"level" = thisRow.ThisLevel
, "levelName" = thisRow.levelName
, "groupName" = thisRow.groupName
, "members" = []
};
keyResult = structFindKey(request.hierarchyStruct, thisKey, "one");
if(arrayLen(keyResult) > 0){
writeDump(keyResult);
newPath = 'request.hierarchyStruct' & keyResult[1].path;
foundKey = structGet(newPath);
foundKey[thisRow.groupId] = newChild;
}
}
I am able to "find the key" which dumps the key result:
But when the first row "Jasmines Region" finds and try to add the "newChild" to it I get an error
I have tried a variety of combinations with the path including
var newPath = keyResult[1].path;
var fullPath = 'request.hierarchyStruct'
var pathArray = listToArray(newPath,'.');
for(i in pathArray){
fullPath = fullpath & "." & i ;
}
I don't know if it matters a lot but I am using the lastest version of LUCEE not adobe's coldfusion.
This is the first time using structFindKey and it's path can anyone shed any light on this???
You may have stumbled upon a bug in Lucee. Your code seems to work with Adobe ColdFusion. I created a gist on TryCF showing this.
<cfscript>
hierarchyStruct = {};
hierarchyStruct.0 = {
"groupName" = "top level"
, "level" = "1"
, "levelName" = "region"
};
writeDump(hierarchyStruct);
keyResult = structFindKey(hierarchyStruct, "0", "one");
writeDump(keyResult);
newPath = 'hierarchyStruct' & keyResult[1].path;
writeDump(newPath);
foundKey = structGet(newPath);
writeDump(foundKey);
</cfscript>
That gist is using Adobe ColdFusion 11 and it will run. Change the engine to Lucee and it will error.
You can get around this error by changing the name of the request.hierarchyStruct.0 structure. Note that it is failing on that structure being named 0.
For example, I created another gist changing the name of that structure to a0 and it works using Lucee.
<cfscript>
hierarchyStruct = {};
hierarchyStruct.a0 = {
"groupName" = "top level"
, "level" = "1"
, "levelName" = "region"
};
writeDump(hierarchyStruct);
keyResult = structFindKey(hierarchyStruct, "a0", "one");
writeDump(keyResult);
newPath = 'hierarchyStruct' & keyResult[1].path;
writeDump(newPath);
foundKey = structGet(newPath);
writeDump(foundKey);
</cfscript>

Customer Action "Extend To Vendor"

Using the latest version of Acumatica 5 with the latest and greatest updates, I’m running into a Web API issue that I have not been able to solve. I have code to execute the “Extend To Vendor” action on the Customer screen. It seems to run fine and does not error out but it fails to create the vendor. It seems to me that when performing the same actions through the website interface, the issue is that I’m not sending the correct command to choose the “Yes” button on the popup Warning box “Please confirm if you want to update current Vendor settings with the Vendor Class defaults. Original settings will be perserved otherwise.” I could be totally off though and any help would be greatly appreciated.
Here is my code:
String customerId = "SomeCustomerId";
String vendorClass = “SomeVendorClass”;
AcumaticaApiWS.AR303000Content AR303000 = context.AR303000GetSchema();
AcumaticaApiWS.AP303000Content AP303000 = context.AP303000GetSchema();
context.AR303000Clear();
AR303000.Actions.ExtendToVendor.Commit = true;
AcumaticaApiWS.AR303000Content[] AR303000result = context.AR303000Submit
(
new AcumaticaApiWS.Command[]
{
new AcumaticaApiWS.Value { Value = customerId, LinkedCommand = AR303000.CustomerSummary.CustomerID },
AR303000.Actions.ExtendToVendor
}
);
AcumaticaApiWS.AP303000Content[] AP303000result = context.AP303000Submit
(
new AcumaticaApiWS.Command[]
{
new AcumaticaApiWS.Value { Value = vendorClass, LinkedCommand = AP303000.GeneralInfoFinancialSettings.VendorClass },
new AcumaticaApiWS.Value { Value = "YES", LinkedCommand = AP303000.GeneralInfoFinancialSettings.ServiceCommands.DialogAnswer, Commit = true },
AP303000.Actions.Save
}
);
Thanks!
You're almost there. This is not an easy scenario since it involves multiple screens and dialogs, two things which are not trivial to use. The issues in your code sample are:
The dialog answer has to be set before the value. In your case, you're setting the vendor class first. This is counter-intuitive but the system has to know it before the dialog is displayed
The dialog answer is "Yes", and not "YES". You can see this by using the web browser inspector window and looking at the button title. The text is displayed in uppercase due to CSS styling.
You need to set the dialog answer on the primary view of the form (AP303000.VendorSummary.ServiceCommands.DialogAnswer), where the dialog is being displayed. There's no way to know this without looking at the source code, but I believe this is generally the case with dialog boxes.
The different Commit = true settings are not necessary (but don't hurt in this case).
This is the code I used, and in my case it extends a customer to a vendor and changes the vendor class at the same time:
String customerId = "ACTIVESTAF";
String vendorClass = "DATACENTER";
AcumaticaApiWS.AR303000Content AR303000 = context.AR303000GetSchema();
AcumaticaApiWS.AP303000Content AP303000 = context.AP303000GetSchema();
context.AR303000Clear();
AcumaticaApiWS.AR303000Content[] AR303000result = context.AR303000Submit
(
new AcumaticaApiWS.Command[]
{
new AcumaticaApiWS.Value { Value = customerId, LinkedCommand = AR303000.CustomerSummary.CustomerID },
AR303000.Actions.ExtendToVendor
}
);
AcumaticaApiWS.AP303000Content[] AP303000result = context.AP303000Submit
(
new AcumaticaApiWS.Command[]
{
new AcumaticaApiWS.Value { Value = "Yes", LinkedCommand = AP303000.VendorSummary.ServiceCommands.DialogAnswer },
new AcumaticaApiWS.Value { Value = vendorClass, LinkedCommand = AP303000.GeneralInfoFinancialSettings.VendorClass },
AP303000.Actions.Save
}
);

Resources