mulang 6.0.2 → 6.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fccc6ae521b7cc8afb96206ab3cefde9cc8a5de2a0372f98b1d8aeacc4814bb
4
- data.tar.gz: 77da683de43a57b229051476ff2e1d9ed78095859e0aa2e69874b86182e03df4
3
+ metadata.gz: ed2cc9afb7a5806ef5d23b16b50a73715c7e28139f9d00fda289e3b5d5143aac
4
+ data.tar.gz: 39377950e8526e6733b93009cabe5fab5d819f55fbc1bde22e5a4c267abbd4f9
5
5
  SHA512:
6
- metadata.gz: a0473f1cd8c078c3c61b11d217628be7fa2d745ee356ea484214e58c70ef0ef722ae752e40f6aae17cf704d6eb18838ada30c13977af89cd1f9b203219f47299
7
- data.tar.gz: 9d94d6e7acd22e9c9fe6545207810c6b4c88b33f7c55689eb8a20e25732b19387d45f04acb3254ee7ffbbd79544937076b1c77238e968d97fde9d9c8bfa94841
6
+ metadata.gz: 756137cb06b723f815f23a03503f829eeb6b42321e3c8f3be48fe514d1533beae09da00cf43f4bc6ec124778b5b85f3e7e719d71b06eb5bcf12063d6f7372103
7
+ data.tar.gz: 2efd5733997a5f2f4012d353178579c3353ab52655512b77df580e57024c82696ba5a57d9fefe8deab80044896379aa5d511cc150fca33001dec387f1927bc7d
data/bin/mulang CHANGED
Binary file
data/lib/locales/en.yml CHANGED
@@ -171,8 +171,8 @@ en:
171
171
  UsesComprehension: '%{binding} %{must} use comprehensions'
172
172
  UsesConditional: '%{binding} %{must} use conditionals'
173
173
  UsesCut: '%{binding} uses <code>!</li> operator, which is a bad practice'
174
- UsesDyamicPolymorphism: '%{binding} %{must} use polymorphism'
175
174
  UsesDynamicMethodOverload: '%{binding} %{must} use overload'
175
+ UsesDynamicPolymorphism: '%{binding} %{must} use polymorphism'
176
176
  UsesFail: '%{binding} uses <code>%{keyword_Fail}</li>, which is a bad practice'
177
177
  UsesFindall: '%{binding} %{must} use <code>%{keyword_Findall}</code>'
178
178
  UsesForall: '%{binding} %{must} use <code>%{keyword_Forall}</code>'
@@ -185,6 +185,7 @@ en:
185
185
  UsesLoop: '%{binding} %{must} use a loop%{matching}'
186
186
  UsesMath: '%{binding} %{must} usar math expressions'
187
187
  UsesMixin: '%{binding} %{must} use mixins'
188
+ UsesNamedSelfReference: '%{binding} should use <code>%{keyword_Self}</code> instead of a global reference'
188
189
  UsesNot: '%{binding} %{must} use not'
189
190
  UsesObjectComposition: '%{binding} %{must} use composition'
190
191
  UsesPatternMatching: '%{binding} %{must} use pattern matching'
data/lib/locales/es.yml CHANGED
@@ -183,8 +183,8 @@ es:
183
183
  UsesComprehension: '%{binding} %{must} emplear listas por comprensión'
184
184
  UsesConditional: '%{binding} %{must} utilizar condicionales'
185
185
  UsesCut: '%{binding} usa el operador !, lo cual es una mala práctica'
186
- UsesDyamicPolymorphism: '%{binding} %{must} usar polimorfismo'
187
186
  UsesDynamicMethodOverload: '%{binding} %{must} usar sobrecarga'
187
+ UsesDynamicPolymorphism: '%{binding} %{must} usar polimorfismo'
188
188
  UsesExceptionHandling: '%{binding} %{must} realizar manejo de excepciones'
189
189
  UsesExceptions: '%{binding} %{must} usar excepciones'
190
190
  UsesFail: '%{binding} usa <code>%{keyword_Fail}</li>, lo cual es una mala práctica'
@@ -201,6 +201,7 @@ es:
201
201
  UsesMath: '%{binding} %{must} usar expresiones matemáticas'
202
202
  UsesMixin: '%{binding} %{must} utilizar mixins'
203
203
  UsesMixins: '%{binding} %{must} usar mixins'
204
+ UsesNamedSelfReference: '%{binding} debería usar <code>%{keyword_Self}</code> en lugar de una referencia global'
204
205
  UsesNot: '%{binding} %{must} utilizar <code>%{keyword_Not}</code>'
205
206
  UsesObjectComposition: '%{binding} %{must} usar composición'
206
207
  UsesPatternMatching: '%{binding} %{must} utilizar pattern matching'
data/lib/locales/pt.yml CHANGED
@@ -145,7 +145,7 @@ pt:
145
145
  Instantiates_named: '%{binding} %{must} instantiate %{target}'
146
146
  Instantiates: '%{binding} %{must} instanciar objetos'
147
147
  IsLongCode: '%{binding} é muito longo. Tente delegar mais'
148
- JavaScript#UsesVarInsteadOfLet: '% {binding} deve usar <code>let</code> em vez de <code>var</code>'
148
+ JavaScript#UsesVarInsteadOfLet: '%{binding} deve usar <code>let</code> em vez de <code>var</code>'
149
149
  OverridesEqualOrHashButNotBoth: '%{binding} redefine os métodos <code>equals</code> ou <code>hash </code>, mas não ambos'
150
150
  Raises_except: '%{binding} %{must} lançar exceções diferentes de %{target}'
151
151
  Raises_like: '%{binding} %{must} lançar exceções semelhantes a %{target}'
@@ -175,8 +175,8 @@ pt:
175
175
  UsesComprehension: '%{binding} %{must} usar listas pelo entendimento'
176
176
  UsesConditional: '%{binding} %{must} usar conditional'
177
177
  UsesCut: '%{binding} usa o operador !, que é uma má prática'
178
- UsesDyamicPolymorphism: '%{binding} %{must} usar polimorfismo'
179
178
  UsesDynamicMethodOverload: '%{binding} %{must} usar sobrecarga'
179
+ UsesDynamicPolymorphism: '%{binding} %{must} usar polimorfismo'
180
180
  UsesExceptionHandling: '%{binding} %{must} executar o tratamento de exceção'
181
181
  UsesExceptions: '%{binding} %{must} usar exceções'
182
182
  UsesFail: '%{binding} usa <code>%{keyword_Fail}</li>, o que é uma prática ruim'
@@ -192,6 +192,7 @@ pt:
192
192
  UsesLoop: '%{binding} %{must} usar um loop%{matching}'
193
193
  UsesMath: '%{binding} %{must} usar expressões matemáticas'
194
194
  UsesMixins: '%{binding} %{must} usar mixins'
195
+ UsesNamedSelfReference: '%{binding} deve usar <code>%{keyword_Self}</code> em vez de uma referência global'
195
196
  UsesNot: '%{binding} %{must} usar <code>%{keyword_Not}</code>'
196
197
  UsesObjectComposition: '%{binding} %{must} usar composição'
197
198
  UsesPatternMatching: '%{binding} %{must} usar o padrão de correspondência'
data/lib/mulang/code.rb CHANGED
@@ -30,8 +30,8 @@ module Mulang
30
30
  @language.sample @content
31
31
  end
32
32
 
33
- def analysis(spec)
34
- { sample: sample, spec: spec }
33
+ def analysis(spec, **options)
34
+ @language.build_analysis @content, spec, **options
35
35
  end
36
36
 
37
37
  def analyse(spec, **options)
@@ -8,6 +8,7 @@ module Mulang::Expectation
8
8
 
9
9
  FUNCTIONAL_SMELLS = %w(
10
10
  HasRedundantGuards
11
+ HasRedundantLambda
11
12
  HasRedundantParameter
12
13
  ShouldUseOtherwise
13
14
  )
@@ -15,11 +16,12 @@ module Mulang::Expectation
15
16
  OBJECT_ORIENTED_SMELLS = %w(
16
17
  DoesNilTest
17
18
  DoesNullTest
19
+ DoesTypeTest
18
20
  HasTooManyMethods
19
21
  OverridesEqualOrHashButNotBoth
20
22
  ReturnsNil
21
23
  ReturnsNull
22
- DoesTypeTest
24
+ UsesNamedSelfReference
23
25
  )
24
26
 
25
27
  IMPERATIVE_SMELLS = %w(
@@ -32,6 +34,7 @@ module Mulang::Expectation
32
34
  EXPRESSIVENESS_SMELLS = %w(
33
35
  HasMisspelledBindings
34
36
  HasMisspelledIdentifiers
37
+ HasTooShortBindings
35
38
  HasTooShortIdentifiers
36
39
  HasWrongCaseBinding
37
40
  HasWrongCaseIdentifiers
@@ -46,10 +49,8 @@ module Mulang::Expectation
46
49
  HasEqualIfBranches
47
50
  HasLongParameterList
48
51
  HasRedundantBooleanComparison
49
- HasRedundantLocalVariableReturn
50
52
  HasRedundantIf
51
- HasRedundantLambda
52
- HasTooShortBindings
53
+ HasRedundantLocalVariableReturn
53
54
  HasUnreachableCode
54
55
  HasUsageTypos
55
56
  IsLongCode
@@ -72,7 +73,7 @@ module Mulang::Expectation
72
73
  def self.guess_type(expectation)
73
74
  if expectation[:binding] == '<<custom>>'
74
75
  Custom
75
- elsif expectation[:inspection] =~ /(Not\:)?Has.*/ && !has_smell?(expectation[:inspection])
76
+ elsif expectation[:inspection] =~ /^(Not\:)?Has.*/ && !has_smell?(expectation[:inspection])
76
77
  V0
77
78
  else
78
79
  V2
@@ -1,11 +1,25 @@
1
1
  module Mulang::Language
2
+ CORE_LANGUAGES = %w(
3
+ Java
4
+ JavaScript
5
+ Prolog
6
+ Haskell
7
+ Python
8
+ Python2
9
+ Python3
10
+ Ruby
11
+ Php
12
+ C
13
+ Mulang
14
+ )
15
+
2
16
  class Base
3
17
  def identifiers(content, **options)
4
18
  Mulang.analyse(identifiers_analysis(content, **options), **options)['outputIdentifiers'] rescue nil
5
19
  end
6
20
 
7
21
  def identifiers_analysis(content, **options)
8
- base_analysis content, {includeOutputIdentifiers: true}, **options
22
+ build_analysis content, {includeOutputIdentifiers: true}, **options
9
23
  end
10
24
 
11
25
  def transformed_asts(content, operations, **options)
@@ -13,7 +27,7 @@ module Mulang::Language
13
27
  end
14
28
 
15
29
  def transformed_asts_analysis(content, operations, **options)
16
- base_analysis content, {transformationSpecs: operations}, **options
30
+ build_analysis content, {transformationSpecs: operations}, **options
17
31
  end
18
32
 
19
33
  def normalization_options(**options)
@@ -25,12 +39,10 @@ module Mulang::Language
25
39
  end
26
40
 
27
41
  def ast_analysis(content, **options)
28
- base_analysis content, {includeOutputAst: true}, **options
42
+ build_analysis content, {includeOutputAst: true}, **options
29
43
  end
30
44
 
31
- private
32
-
33
- def base_analysis(content, spec, **options)
45
+ def build_analysis(content, spec, **options)
34
46
  {
35
47
  sample: sample(content),
36
48
  spec: {
@@ -57,6 +69,10 @@ module Mulang::Language
57
69
  content: content
58
70
  }
59
71
  end
72
+
73
+ def core_name
74
+ @name
75
+ end
60
76
  end
61
77
 
62
78
  class External < Base
@@ -82,8 +98,12 @@ module Mulang::Language
82
98
  }
83
99
  end
84
100
 
85
- def base_analysis(*)
86
- super.deep_merge(spec: {originalLanguage: @name}.compact)
101
+ def build_analysis(*)
102
+ super.deep_merge(spec: {originalLanguage: core_name}.compact)
103
+ end
104
+
105
+ def core_name
106
+ @name.in?(CORE_LANGUAGES) ? name : nil
87
107
  end
88
108
 
89
109
  private
data/lib/mulang/tokens.rb CHANGED
@@ -92,6 +92,7 @@ module Mulang
92
92
  keyword_ForEach: 'for',
93
93
  keyword_Interface: 'interface',
94
94
  keyword_Switch: 'switch',
95
+ keyword_Self: 'this',
95
96
  operator_And: '&amp;&amp;',
96
97
  operator_Divide: '/',
97
98
  operator_Equal: 'equal',
@@ -123,6 +124,7 @@ module Mulang
123
124
  keyword_If: 'if',
124
125
  keyword_Return: 'return',
125
126
  keyword_While: 'while',
127
+ keyword_Self: 'this',
126
128
  operator_And: '&amp;&amp;',
127
129
  operator_Divide: '/',
128
130
  operator_Equal: '===',
@@ -155,6 +157,7 @@ module Mulang
155
157
  keyword_If: 'if',
156
158
  keyword_Return: 'return',
157
159
  keyword_While: 'while',
160
+ keyword_Self: 'self',
158
161
  operator_And: 'and',
159
162
  operator_Divide: '/',
160
163
  operator_Equal: '==',
@@ -188,6 +191,7 @@ module Mulang
188
191
  keyword_ForEach: 'for',
189
192
  keyword_Include: 'include',
190
193
  keyword_Switch: 'case',
194
+ keyword_Self: 'self',
191
195
  operator_And: '&amp;&amp;',
192
196
  operator_Divide: '/',
193
197
  operator_Equal: '==',
@@ -207,6 +211,7 @@ module Mulang
207
211
  operator_BitwiseXor: '^',
208
212
  operator_BitwiseLeftShift: '&lt;&lt;',
209
213
  operator_BitwiseRightShift: '&gt;&gt;',
214
+ operator_Size: 'length',
210
215
  operator_Hash: 'hash',
211
216
  operator_ForwardComposition: '&gt;&gt;',
212
217
  operator_BackwardComposition: '&lt;&lt;'
@@ -219,6 +224,7 @@ module Mulang
219
224
  keyword_If: 'if',
220
225
  keyword_Return: 'return',
221
226
  keyword_While: 'while',
227
+ keyword_Self: 'this',
222
228
  operator_And: '&amp;&amp;',
223
229
  operator_Divide: '/',
224
230
  operator_Equal: '==',
@@ -1,4 +1,4 @@
1
1
  module Mulang
2
- VERSION = "6.0.2"
3
- MULANG_VERSION = "6.0.2"
2
+ VERSION = "6.0.6"
3
+ MULANG_VERSION = "6.0.6"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mulang
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 6.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-28 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit-core