Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8c21a28

Browse files
author
unibeautify[bot]
committed
🎨 Fix formatting of 14 files for commitb3be065
1 parentb3be065 commit8c21a28

14 files changed

+213
-157
lines changed

‎src/minClassCohesionRule.ts‎

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,18 @@ class ClassDeclarationHelper {
105105
}
106106

107107
privategetmethods():ts.MethodDeclaration[]{
108-
return<ts.MethodDeclaration[]>this.node.members.filter((classElement:ts.ClassElement):boolean=>{
109-
switch(classElement.kind){
110-
casets.SyntaxKind.MethodDeclaration:
111-
casets.SyntaxKind.GetAccessor:
112-
casets.SyntaxKind.SetAccessor:
113-
return!AstUtils.isStatic(classElement);
114-
default:
115-
returnfalse;
108+
return<ts.MethodDeclaration[]>this.node.members.filter(
109+
(classElement:ts.ClassElement):boolean=>{
110+
switch(classElement.kind){
111+
casets.SyntaxKind.MethodDeclaration:
112+
casets.SyntaxKind.GetAccessor:
113+
casets.SyntaxKind.SetAccessor:
114+
return!AstUtils.isStatic(classElement);
115+
default:
116+
returnfalse;
117+
}
116118
}
117-
});
119+
);
118120
}
119121

120122
privatenumberOfFieldsUsedByMethod(fieldNames:string[],method:ts.MethodDeclaration):number{
@@ -134,21 +136,23 @@ class ClassDeclarationHelper {
134136
privategetconstructorParameters():ts.ParameterDeclaration[]{
135137
constctor:ts.ConstructorDeclaration=this.constructorDeclaration;
136138
if(ctor){
137-
returnctor.parameters.filter((param:ts.ParameterDeclaration):boolean=>{
138-
return(
139-
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.PublicKeyword)||
140-
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.PrivateKeyword)||
141-
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.ProtectedKeyword)||
142-
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.ReadonlyKeyword)
143-
);
144-
});
139+
returnctor.parameters.filter(
140+
(param:ts.ParameterDeclaration):boolean=>{
141+
return(
142+
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.PublicKeyword)||
143+
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.PrivateKeyword)||
144+
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.ProtectedKeyword)||
145+
AstUtils.hasModifier(param.modifiers,ts.SyntaxKind.ReadonlyKeyword)
146+
);
147+
}
148+
);
145149
}
146150
return[];
147151
}
148152

149153
privategetconstructorDeclaration():ts.ConstructorDeclaration|undefined{
150-
return<ts.ConstructorDeclaration>this.node.members.find(
151-
(element:ts.ClassElement):boolean=>element.kind===ts.SyntaxKind.Constructor
154+
return<ts.ConstructorDeclaration>(
155+
this.node.members.find((element:ts.ClassElement):boolean=>element.kind===ts.SyntaxKind.Constructor)
152156
);
153157
}
154158

@@ -157,8 +161,8 @@ class ClassDeclarationHelper {
157161
}
158162

159163
privategetinstanceFields():ts.PropertyDeclaration[]{
160-
return<ts.PropertyDeclaration[]>this.node.members.filter(
161-
(classElement:ts.ClassElement):boolean=>classElement.kind===ts.SyntaxKind.PropertyDeclaration
164+
return<ts.PropertyDeclaration[]>(
165+
this.node.members.filter((classElement:ts.ClassElement):boolean=>classElement.kind===ts.SyntaxKind.PropertyDeclaration)
162166
);
163167
}
164168

@@ -169,9 +173,12 @@ class ClassDeclarationHelper {
169173
}
170174

171175
publicgetextendsSomething():boolean{
172-
returnUtils.exists(this.node.heritageClauses,(clause:ts.HeritageClause):boolean=>{
173-
returnclause.token===ts.SyntaxKind.ExtendsKeyword;
174-
});
176+
returnUtils.exists(
177+
this.node.heritageClauses,
178+
(clause:ts.HeritageClause):boolean=>{
179+
returnclause.token===ts.SyntaxKind.ExtendsKeyword;
180+
}
181+
);
175182
}
176183

177184
publicgetname(){

‎src/newspaperOrderRule.ts‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,18 @@ class ClassDeclarationHelper extends NewspaperHelper {
238238

239239
@Memoize
240240
protectedgetmethods():ts.MethodDeclaration[]{
241-
return<ts.MethodDeclaration[]>this.node.members.filter((classElement:ts.ClassElement):boolean=>{
242-
switch(classElement.kind){
243-
casets.SyntaxKind.MethodDeclaration:
244-
casets.SyntaxKind.GetAccessor:
245-
casets.SyntaxKind.SetAccessor:
246-
return!AstUtils.isStatic(classElement);
247-
default:
248-
returnfalse;
241+
return<ts.MethodDeclaration[]>this.node.members.filter(
242+
(classElement:ts.ClassElement):boolean=>{
243+
switch(classElement.kind){
244+
casets.SyntaxKind.MethodDeclaration:
245+
casets.SyntaxKind.GetAccessor:
246+
casets.SyntaxKind.SetAccessor:
247+
return!AstUtils.isStatic(classElement);
248+
default:
249+
returnfalse;
250+
}
249251
}
250-
});
252+
);
251253
}
252254

253255
@Memoize
@@ -263,11 +265,11 @@ abstract class BlockLikeHelper extends NewspaperHelper {
263265

264266
@Memoize
265267
protectedgetmethods():ts.FunctionDeclaration[]{
266-
constfunctionDeclarations=<ts.FunctionDeclaration[]>this.node.statements.filter((node:ts.Statement):boolean=>
267-
ts.isFunctionDeclaration(node)
268+
constfunctionDeclarations=<ts.FunctionDeclaration[]>(
269+
this.node.statements.filter((node:ts.Statement):boolean=>ts.isFunctionDeclaration(node))
268270
);
269-
constvariableStatements=<ts.VariableStatement[]>this.node.statements.filter((node:ts.Statement):boolean=>
270-
ts.isVariableStatement(node)
271+
constvariableStatements=<ts.VariableStatement[]>(
272+
this.node.statements.filter((node:ts.Statement):boolean=>ts.isVariableStatement(node))
271273
);
272274
constvariableFunctionDeclarations:ts.FunctionDeclaration[]=variableStatements
273275
.map(node=>node.declarationList.declarations)

‎src/noComplexConditionalsRule.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export class Rule extends Lint.Rules.AbstractRule {
2424
commonWeaknessEnumeration:'',// if possible, please map your rule to a CWE (see cwe_descriptions.json and https://cwe.mitre.org)
2525
};
2626

27-
publicstaticFAILURE_STRING:string='Conditional expression is too complex. '+
28-
'Consider moving expression to a variable or function with a meaningful name.';
27+
publicstaticFAILURE_STRING:string=
28+
'Conditional expression is too complex. '+'Consider moving expression to a variable or function with a meaningful name.';
2929

3030
publicapply(sourceFile:ts.SourceFile):Lint.RuleFailure[]{
3131
returnthis.applyWithWalker(newNoComplexConditionalsRuleWalker(sourceFile,this.getOptions()));

‎src/noFeatureEnvyRule.ts‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,18 @@ class NoFeatureEnvyRuleWalker extends ErrorTolerantWalker {
9494
}
9595

9696
protectedmethodsForClass(classNode:ts.ClassDeclaration):ts.MethodDeclaration[]{
97-
return<ts.MethodDeclaration[]>classNode.members.filter((classElement:ts.ClassElement):boolean=>{
98-
switch(classElement.kind){
99-
casets.SyntaxKind.MethodDeclaration:
100-
casets.SyntaxKind.GetAccessor:
101-
casets.SyntaxKind.SetAccessor:
102-
return!AstUtils.isStatic(classElement);
103-
default:
104-
returnfalse;
97+
return<ts.MethodDeclaration[]>classNode.members.filter(
98+
(classElement:ts.ClassElement):boolean=>{
99+
switch(classElement.kind){
100+
casets.SyntaxKind.MethodDeclaration:
101+
casets.SyntaxKind.GetAccessor:
102+
casets.SyntaxKind.SetAccessor:
103+
return!AstUtils.isStatic(classElement);
104+
default:
105+
returnfalse;
106+
}
105107
}
106-
});
108+
);
107109
}
108110

109111
privateparseOptions():void{

‎src/noForEachPushRule.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class Rule extends Lint.Rules.AbstractRule {
2828
returnthis.applyWithWalker(newNoForeachPushRuleWalker(sourceFile,this.getOptions()));
2929
}
3030

31-
publicstaticFAILURE_STRING:string='Do not use Array.prototype.push inside of Array.prototype.forEach. '+
32-
'Use Array.prototype.map instead to replace both.';
31+
publicstaticFAILURE_STRING:string=
32+
'Do not use Array.prototype.push inside of Array.prototype.forEach. '+'Use Array.prototype.map instead to replace both.';
3333
}
3434

3535
classNoForeachPushRuleWalkerextendsErrorTolerantWalker{

‎src/noMapWithoutUsageRule.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export class Rule extends Lint.Rules.AbstractRule {
2424
commonWeaknessEnumeration:'',// if possible, please map your rule to a CWE (see cwe_descriptions.json and https://cwe.mitre.org)
2525
};
2626

27-
publicstaticFAILURE_STRING:string='Return value from Array.prototype.map should be assigned to a variable. '+
28-
'Consider using Array.prototype.forEach instead.';
27+
publicstaticFAILURE_STRING:string=
28+
'Return value from Array.prototype.map should be assigned to a variable. '+'Consider using Array.prototype.forEach instead.';
2929

3030
publicapply(sourceFile:ts.SourceFile):Lint.RuleFailure[]{
3131
returnthis.applyWithWalker(newNoMapWithoutAssignmentRuleWalker(sourceFile,this.getOptions()));

‎src/tests/MinClassCohesionRuleTests.ts‎

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,20 @@ describe('minClassCohesionRule', (): void => {
215215
TestHelper.assertViolations(ruleName,script,[]);
216216
});
217217

218-
context('reading options',():void=>{
219-
context('90% cohesion',():void=>{
220-
letoptions:any[];
218+
context(
219+
'reading options',
220+
():void=>{
221+
context(
222+
'90% cohesion',
223+
():void=>{
224+
letoptions:any[];
221225

222-
beforeEach(():void=>{
223-
options=[true,0.9];
224-
});
226+
beforeEach(():void=>{
227+
options=[true,0.9];
228+
});
225229

226-
it('should fail on Stack class',():void=>{
227-
constscript:string=`
230+
it('should fail on Stack class',():void=>{
231+
constscript:string=`
228232
class Stack {
229233
private topOfStack: number = 0;
230234
private elements: number[] = [];
@@ -244,26 +248,29 @@ describe('minClassCohesionRule', (): void => {
244248
}
245249
}
246250
`;
247-
TestHelper.assertViolationsWithOptions(ruleName,options,script,[
248-
{
249-
failure:FAILURE_STRING+'Stack',
250-
name:'file.ts',
251-
ruleName:'min-class-cohesion',
252-
startPosition:{character:17,line:2},
253-
},
254-
]);
255-
});
256-
});
251+
TestHelper.assertViolationsWithOptions(ruleName,options,script,[
252+
{
253+
failure:FAILURE_STRING+'Stack',
254+
name:'file.ts',
255+
ruleName:'min-class-cohesion',
256+
startPosition:{character:17,line:2},
257+
},
258+
]);
259+
});
260+
}
261+
);
257262

258-
context('80% cohesion',():void=>{
259-
letoptions:any[];
263+
context(
264+
'80% cohesion',
265+
():void=>{
266+
letoptions:any[];
260267

261-
beforeEach(():void=>{
262-
options=[true,0.8];
263-
});
268+
beforeEach(():void=>{
269+
options=[true,0.8];
270+
});
264271

265-
it('should pass on Stack class',():void=>{
266-
constscript:string=`
272+
it('should pass on Stack class',():void=>{
273+
constscript:string=`
267274
class Stack {
268275
private topOfStack: number = 0;
269276
private elements: number[] = [];
@@ -283,8 +290,10 @@ describe('minClassCohesionRule', (): void => {
283290
}
284291
}
285292
`;
286-
TestHelper.assertViolationsWithOptions(ruleName,options,script,[]);
287-
});
288-
});
289-
});
293+
TestHelper.assertViolationsWithOptions(ruleName,options,script,[]);
294+
});
295+
}
296+
);
297+
}
298+
);
290299
});

‎src/tests/TestHelper.ts‎

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,28 +148,34 @@ export namespace TestHelper {
148148
// All the information we need is line and character of start position. For JSON comparison
149149
// to work, we will delete the information that we are not interested in from both actual and
150150
// expected failures.
151-
actualFailures.forEach((actual:ExpectedFailure):void=>{
152-
deleteactual.startPosition.position;
153-
deleteactual.endPosition;
154-
// Editors start counting lines and characters from 1, but tslint does it from 0.
155-
// To make thing easier to debug, align to editor values.
156-
actual.startPosition.line=actual.startPosition.line+1;
157-
actual.startPosition.character=actual.startPosition.character+1;
158-
});
159-
expectedFailures.forEach((expected:ExpectedFailure):void=>{
160-
deleteexpected.startPosition.position;
161-
deleteexpected.endPosition;
162-
if(!expected.ruleSeverity){
163-
expected.ruleSeverity='ERROR';
151+
actualFailures.forEach(
152+
(actual:ExpectedFailure):void=>{
153+
deleteactual.startPosition.position;
154+
deleteactual.endPosition;
155+
// Editors start counting lines and characters from 1, but tslint does it from 0.
156+
// To make thing easier to debug, align to editor values.
157+
actual.startPosition.line=actual.startPosition.line+1;
158+
actual.startPosition.character=actual.startPosition.character+1;
164159
}
165-
});
160+
);
161+
expectedFailures.forEach(
162+
(expected:ExpectedFailure):void=>{
163+
deleteexpected.startPosition.position;
164+
deleteexpected.endPosition;
165+
if(!expected.ruleSeverity){
166+
expected.ruleSeverity='ERROR';
167+
}
168+
}
169+
);
166170

167171
consterrorMessage=`Wrong # of failures: \n${JSON.stringify(actualFailures,null,2)}`;
168172
chai.assert.equal(actualFailures.length,expectedFailures.length,errorMessage);
169173

170-
expectedFailures.forEach((expected:ExpectedFailure,index:number):void=>{
171-
constactual=actualFailures[index];
172-
chai.assert.deepEqual(actual,expected);
173-
});
174+
expectedFailures.forEach(
175+
(expected:ExpectedFailure,index:number):void=>{
176+
constactual=actualFailures[index];
177+
chai.assert.deepEqual(actual,expected);
178+
}
179+
);
174180
}
175181
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp