-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix UI defect RAC-4416 #549
Conversation
lib/task-graph.js
Outdated
return store.getTaskDefinition(taskData.taskName) | ||
var taskName = new String(taskData.taskName); | ||
var contains = taskName.indexOf("\/"); | ||
if(contains != null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected '!==' and instead saw '!='.
lib/task-graph.js
Outdated
@@ -360,7 +366,13 @@ function taskGraphFactory( | |||
assert.arrayOfObject(self.definition.tasks, 'Graph.tasks'); | |||
return Promise.map(self.definition.tasks, function(taskData) { | |||
if (!_.has(taskData, 'taskDefinition')) { | |||
return store.getTaskDefinition(taskData.taskName) | |||
var taskName = new String(taskData.taskName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use String as a constructor.
lib/task-graph.js
Outdated
@@ -210,8 +210,14 @@ function taskGraphFactory( | |||
}; | |||
|
|||
if (taskData.taskName) { | |||
var taskName = new String(taskData.taskName); | |||
var contains = taskName.indexOf("\/"); | |||
if(contains != null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected '!==' and instead saw '!='.
lib/task-graph.js
Outdated
@@ -210,8 +210,14 @@ function taskGraphFactory( | |||
}; | |||
|
|||
if (taskData.taskName) { | |||
var taskName = new String(taskData.taskName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use String as a constructor.
92a354b
to
50db145
Compare
lib/task-graph.js
Outdated
@@ -208,10 +208,15 @@ function taskGraphFactory( | |||
waitingOn: taskData.waitOn, | |||
ignoreFailure: taskData.ignoreFailure | |||
}; | |||
|
|||
if (taskData.taskName) { | |||
if (taskData.taskName && typeof(taskData.taskName) !== "undefined") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the condition never goto 'typeof(taskData.taskName) !== "undefined"' which after '&&' , right?
lib/task-graph.js
Outdated
if (taskData.taskName && typeof(taskData.taskName) !== "undefined") { | ||
var taskName = taskData.taskName; | ||
var contains = taskName.indexOf("\/"); | ||
if(contains !== -1){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add annotations for string operations
lib/task-graph.js
Outdated
@@ -360,7 +365,15 @@ function taskGraphFactory( | |||
assert.arrayOfObject(self.definition.tasks, 'Graph.tasks'); | |||
return Promise.map(self.definition.tasks, function(taskData) { | |||
if (!_.has(taskData, 'taskDefinition')) { | |||
return store.getTaskDefinition(taskData.taskName) | |||
var taskName = taskData.taskName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated code with above, please extract a function if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, however this line is in the new function.
lib/task-graph.js
Outdated
if (taskData.taskName) { | ||
if (taskData.taskName && typeof(taskData.taskName) !== "undefined") { | ||
var taskName = taskData.taskName; | ||
var contains = taskName.indexOf("\/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contains what, a descriptive name is better
spec/lib/task-graph-spec.js
Outdated
@@ -130,6 +130,13 @@ describe('Task Graph', function () { | |||
expect(graph).to.be.an.instanceof(TaskGraph); | |||
}); | |||
}); | |||
it('should return this', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please choose another description other than "should return this". it was used in line 127
a silly question: |
baf0fcb
to
5ac99e2
Compare
lib/task-graph.js
Outdated
taskName = nameArray[nameArray.length - 1]; | ||
} | ||
return taskName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
lib/task-graph.js
Outdated
@@ -229,7 +235,14 @@ function taskGraphFactory( | |||
return self; | |||
}); | |||
}; | |||
|
|||
var getTaskName = function(taskName){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'getTaskName' was used before it was defined.
lib/task-graph.js
Outdated
taskName = nameArray[nameArray.length - 1]; | ||
} | ||
return taskName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
lib/task-graph.js
Outdated
taskName = nameArray[nameArray.length - 1]; | ||
} | ||
return taskName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon.
bcb7197
to
45d0e72
Compare
lib/task-graph.js
Outdated
var getTaskName = function(taskName){ | ||
// check if there is "/" in the task name ,if yes | ||
// it may have the api path before task name | ||
var contains = taskName.indexOf("\/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temporary variable name could be slashIndex, or slashOffset. I think this is your purpose, it's more straightforward than a verb 'contain', and it's more readable
lib/task-graph.js
Outdated
return store.getTaskDefinition(taskData.taskName) | ||
var taskName = taskData.taskName; | ||
if(taskName){ | ||
taskName = getTaskName(taskName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taskName in this function have two meanings. former taskName is taskName input, latter is true taskName, it's not so good for clean code. so you could naming former one as taskNameInput, the latter is taskName. Otherwise, it's a little werid that get 'taskName' from 'taskName'
can you |
BackGround :
when we create a workflow without task definition , rackhd will add api path to the taskName ,when you change the workflow and need save again , it will failed when validation of the task with taskName like "api/2.0/workflows/tasks****"
Solution :
code change in task-graph.js . when validate ,we use actually task name instead of the whole name witch contains api path
Test :
manual test
Jira:
https://rackhd.atlassian.net/browse/RAC-4416
Reviewer :
@anhou @panpan0000 @bbcyyb