Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gem/lib/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ en:
DeclaresVariable_like: '%{binding} %{must} declare a variable similar to %{target}%{matching}'
DeclaresVariable_named: '%{binding} %{must} declare a variable %{target}%{matching}'
DeclaresVariable: '%{binding} %{must} debe declare variables%{matching}'
Delegates: '%{binding} %{must} delegate'
DiscardsExceptions: '%{binding} is ignoring exceptions silently'
DoesConsolePrint: '%{binding} is printing to the console'
DoesNilTest: '%{binding} does <i>%{keyword_null}</i> tests'
Expand All @@ -105,6 +106,7 @@ en:
HasAssignmentReturn: '%{binding} returns the result of an assignment'
HasCodeDuplication: '%{binding} has code duplication'
HasEmptyIfBranches: '%{binding} has empty <i>%{keyword_if}</i> branches'
HasEmptyRepeat: '%{binding} has empty <i>%{keyword_repeat}</i>'
HasLongParameterList: '%{binding} has too many parameters. You may be missing an abstraction.'
HasMisspelledBindings: '%{binding} is misspelled'
HasMisspelledIdentifiers: '%{binding} is misspelled'
Expand Down
2 changes: 2 additions & 0 deletions gem/lib/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ es:
DeclaresVariable_like: '%{binding} %{must} declarar una variable parecida a %{target}%{matching}'
DeclaresVariable_named: '%{binding} %{must} declarar una variable %{target}%{matching}'
DeclaresVariable: '%{binding} %{must} debe declarar variables%{matching}'
Delegates: '%{binding} %{must} delegar'
DiscardsExceptions: '%{binding} está ignorando excepciones silenciosamiente'
DoesConsolePrint: '%{binding} está realizando impresiones por pantalla'
DoesNilTest: '%{binding} hace comparaciones contra <i>%{keyword_null}</i>'
Expand All @@ -109,6 +110,7 @@ es:
HasAssignmentReturn: '%{binding} devuelve el resultado de una asignación'
HasCodeDuplication: '%{binding} tiene código repetido'
HasEmptyIfBranches: '%{binding} tiene ramas de <i>%{keyword_if}</i> vacías'
HasEmptyRepeat: '%{binding} tiene un <i>%{keyword_repeat}</i> vacío'
HasLongParameterList: '%{binding} tiene demasiados parámetros. Te podría estar faltando una abstracción'
HasMisspelledBindings: '%{binding} está mal escrito. Revisá la ortografía y procurá no usar abreviaturas'
HasMisspelledIdentifiers: '%{binding} está mal escrito. Revisá la ortografía y procurá no usar abreviaturas'
Expand Down
4 changes: 3 additions & 1 deletion gem/lib/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pt:
DeclaresVariable_like: '%{binding} %{must} declarar uma variável semelhante a %{target}%{matching}'
DeclaresVariable_named: '%{binding} %{must} declarar uma variável %{target}%{matching}'
DeclaresVariable: '%{binding} %{must} deve declarar variáveis%{matching}'
Delegates: '%{binding} %{must} delegar'
DiscardsExceptions: '%{binding} está silenciosamente ignorando exceções'
DoesConsolePrint: '%{binding} está fazendo impressões na tela'
DoesNilTest: '%{binding} faz comparações contra <i>%{keyword_null}</i>'
Expand All @@ -109,6 +110,7 @@ pt:
HasAssignmentReturn: '%{binding} retorna o resultado de uma tarefa'
HasCodeDuplication: '%{binding} tem código repetido'
HasEmptyIfBranches: '%{binding} tem vazio <i>%{keyword_if}</i> ramos'
HasEmptyRepeat: '%{binding} tem um <i>%{keyword_repeat}</i> vazio'
HasLongParameterList: '%{binding} tem muitos parâmetros. Você pode estar perdendo uma abstração.'
HasMisspelledBindings: '%{binding} está incorreto. Verifique a ortografia e tente não usar abreviaturas'
HasMisspelledIdentifiers: '%{binding} está incorreto. Verifique a ortografia e tente não usar abreviaturas'
Expand Down Expand Up @@ -143,7 +145,6 @@ pt:
Raises_except: '%{binding} %{must} lançar exceções diferentes de %{target}'
Raises_like: '%{binding} %{must} lançar exceções semelhantes a %{target}'
Raises_named: '%{binding} %{must} launch %{target}'
ShouldInvertIfCondition: '%{binding} deve inverter a condição da <i>%{keyword_if}</i> e trocar as ramos'
Raises: '%{binding} %{must} lançar exceções'
Rescues_except: '%{binding} %{must} capturar exceções que não sejam %{target}'
Rescues_like: '%{binding} %{must} capturar exceções semelhantes a %{target}'
Expand All @@ -152,6 +153,7 @@ pt:
Returns: '%{binding} %{must} retornar%{matching}'
ReturnsNil: '%{binding} retorna nulo, o que é uma prática ruim'
ReturnsNull: '%{binding} retorna nulo, o que é uma prática ruim'
ShouldInvertIfCondition: '%{binding} deve inverter a condição da <i>%{keyword_if}</i> e trocar as ramos'
TypesAs_named: '%{binding} %{must} é do tipo %{target}'
TypesAs: '%{binding} %{must} tem tipo'
TypesReturnAs_named: '%{binding} %{must} tem tipo de valor de retorno %{target}'
Expand Down
2 changes: 1 addition & 1 deletion gem/lib/mulang/expectation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Mulang::Expectation
SMELLS = %w(DiscardsExceptions DoesConsolePrint DoesNilTest DoesNullTest DoesTypeTest
HasAssignmentReturn HasCodeDuplication HasEmptyIfBranches HasRedundantRepeat HasLongParameterList
HasAssignmentReturn HasCodeDuplication HasEmptyIfBranches HasEmptyRepeat HasRedundantRepeat HasLongParameterList
HasMisspelledBindings HasMisspelledIdentifiers
HasRedundantBooleanComparison HasRedundantGuards HasRedundantIf
HasRedundantLambda HasRedundantLocalVariableReturn HasRedundantParameter
Expand Down
6 changes: 6 additions & 0 deletions gem/spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def expectation(binding, inspection)
it { expect(expectation('*', "Assigns:x:WithChar:'a'").translate).to eq("solution must assign <strong>x</strong> with character <i>'a'</i>") }
it { expect(expectation('*', "Assigns:*:WithString:\"hello\"").translate).to eq("solution must perform assignments with string <i>\"hello\"</i>") }
it { expect(expectation('*', "Returns:WithNumber:9").translate).to eq('solution must return with number <i>9</i>') }

it { expect(expectation('foo', 'HasEmptyRepeat').translate).to eq('<strong>foo</strong> has empty <i>repeat</i>') }
end

context 'pt locale' do
Expand All @@ -43,6 +45,8 @@ def expectation(binding, inspection)
it { expect(expectation('*', "Returns:WithFalse").translate).to eq('a solução deve retornar com o valor <i>false</i>') }
it { expect(expectation('*', "UsesRepeat:WithMath").translate).to eq('a solução deve usar <i>repeat</i> com uma expressão matemática') }
it { expect(expectation('*', "Calls:g:WithLiteral").translate).to eq('a solução deve usar <strong>g</strong> com um valor literal') }

it { expect(expectation('foo', 'HasEmptyRepeat').translate).to eq('<strong>foo</strong> tem um <i>repeat</i> vazio') }
end

context 'es locale' do
Expand Down Expand Up @@ -95,6 +99,7 @@ def expectation(binding, inspection)
it { expect(expectation('foo', 'DeclaresMethod:*').translate).to eq('<strong>foo</strong> debe declarar métodos') }
it { expect(expectation('foo', 'Uses:baz').translate).to eq('<strong>foo</strong> debe utilizar <strong>baz</strong>') }
it { expect(expectation('foo', 'Uses').translate).to eq('<strong>foo</strong> debe delegar') }
it { expect(expectation('foo', 'Delegates').translate).to eq('<strong>foo</strong> debe delegar') }
it { expect(expectation('foo', 'UsesForall').translate).to eq('<strong>foo</strong> debe utilizar <i>forall</i>') }

it { expect(expectation('foo', 'Not:Uses:=baz').translate).to eq('<strong>foo</strong> no debe utilizar <strong>baz</strong>') }
Expand Down Expand Up @@ -140,6 +145,7 @@ def expectation(binding, inspection)
it { expect(expectation('foo', 'HasRedundantBooleanComparison').translate).to eq('<strong>foo</strong> hace comparaciones booleanas innecesarias') }
it { expect(expectation('bar', 'UsesFail').translate).to eq('<strong>bar</strong> usa <i>fail</li>, lo cual es una mala práctica') }
it { expect(expectation('foo', 'HasEmptyIfBranches').translate).to eq('<strong>foo</strong> tiene ramas de <i>if</i> vacías') }
it { expect(expectation('foo', 'HasEmptyRepeat').translate).to eq('<strong>foo</strong> tiene un <i>repeat</i> vacío') }
it { expect(expectation('foo', 'ShouldInvertIfCondition').translate).to eq('<strong>foo</strong> debería invertir la condición del <i>if</i> e intercambiar las ramas') }
it { expect(expectation('foo', 'HasRedundantRepeat').translate).to eq('<strong>foo</strong> tiene un <i>repeat</i> innecesario') }
it { expect(expectation('foo', 'HasUnreachableCode').translate).to eq('<strong>foo</strong> tiene código inalcanzable') }
Expand Down
6 changes: 6 additions & 0 deletions ghcjslib/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
DeclaresTypeSignature: (binding, must, target, keyword) => `${binding} ${must} declarar firmas de tipos`,
DeclaresVariable_named: (binding, must, target, keyword) => `${binding} ${must} declarar una variable ${target}`,
DeclaresVariable: (binding, must, target, keyword) => `${binding} ${must} declarar variables`,
Delegates: (binding, must, target, keyword) => `${binding} ${must} delegar`,
DiscardsExceptions: (binding, must, target, keyword) => `${binding} está ignorando excepciones silenciosamiente`,
DoesConsolePrint: (binding, must, target, keyword) => `${binding} está realizando impresiones por pantalla`,
DoesNilTest: (binding, must, target, keyword) => `${binding} hace comparaciones contra <i>${keyword['null']}</i>`,
Expand All @@ -76,6 +77,7 @@
HasAssignmentReturn: (binding, must, target, keyword) => `${binding} devuelve el resultado de una asignación`,
HasCodeDuplication: (binding, must, target, keyword) => `${binding} tiene código repetido`,
HasEmptyIfBranches: (binding, must, target, keyword) => `${binding} tiene ramas de <i>${keyword['if']}</i> vacías`,
HasEmptyRepeat: (binding, must, target, keyword) => `${binding} tiene un <i>${keyword['repeat']}</i> vacío`,
HasLongParameterList: (binding, must, target, keyword) => `${binding} tiene demasiados parámetros. Te podría estar faltando una abstracción`,
HasMisspelledBindings: (binding, must, target, keyword) => `${binding} está mal escrito. Revisá la ortografía y procurá no usar abreviaturas`,
HasMisspelledIdentifiers: (binding, must, target, keyword) => `${binding} está mal escrito. Revisá la ortografía y procurá no usar abreviaturas`,
Expand Down Expand Up @@ -203,6 +205,7 @@
DeclaresTypeSignature: (binding, must, target, keyword) => `${binding} ${must} declare type signatures`,
DeclaresVariable_named: (binding, must, target, keyword) => `${binding} ${must} declare a variable ${target}`,
DeclaresVariable: (binding, must, target, keyword) => `${binding} ${must} declare variables`,
Delegates: (binding, must, target, keyword) => `${binding} ${must} delegate`,
DiscardsExceptions: (binding, must, target, keyword) => `${binding} is ignoring exceptions silently`,
DoesConsolePrint: (binding, must, target, keyword) => `${binding} is printing to the console`,
DoesNilTest: (binding, must, target, keyword) => `${binding} does <i>${keyword['null']}</i> tests`,
Expand All @@ -211,6 +214,7 @@
HasAssignmentReturn: (binding, must, target, keyword) => `${binding} returns the result of an assignment`,
HasCodeDuplication: (binding, must, target, keyword) => `${binding} has code duplication`,
HasEmptyIfBranches: (binding, must, target, keyword) => `${binding} has empty <i>${keyword['if']}</i> branches`,
HasEmptyRepeat: (binding, must, target, keyword) => `${binding} has empty an <i>${keyword['repeat']}</i>`,
HasLongParameterList: (binding, must, target, keyword) => `${binding} has too many parameters. You may be missing an abstraction.`,
HasMisspelledBindings: (binding, must, target, keyword) => `${binding} is misspelled`,
HasMisspelledIdentifiers: (binding, must, target, keyword) => `${binding} is misspelled`,
Expand Down Expand Up @@ -331,6 +335,7 @@
DeclaresTypeSignature: (binding, must, target, keyword) => `${binding} ${must} excluir assinaturas de tipo`,
DeclaresVariable_named: (binding, must, target, keyword) => `${binding} ${must} declarar uma variável ${target}`,
DeclaresVariable: (binding, must, target, keyword) => `${binding} ${must} declarar variáveis`,
Delegates: (binding, must, target, keyword) => `${binding} ${must} delegar`,
DiscardsExceptions: (binding, must, target, keyword) => `${binding} está silenciosamente ignorando exceções`,
DoesConsolePrint: (binding, must, target, keyword) => `${binding} está fazendo impressões na tela`,
DoesNilTest: (binding, must, target, keyword) => `${binding} faz comparações contra <i>${keyword['null']}</i>`,
Expand All @@ -339,6 +344,7 @@
HasAssignmentReturn: (binding, must, target, keyword) => `${binding} retorna o resultado de uma tarefa`,
HasCodeDuplication: (binding, must, target, keyword) => `${binding} tem código repetido`,
HasEmptyIfBranches: (binding, must, target, keyword) => `${binding} tem vazio <i>${keyword['if']}</i> ramos`,
HasEmptyRepeat: (binding, must, target, keyword) => `${binding} tem um <i>${keyword['repeat']}</i> vazio`,
HasLongParameterList: (binding, must, target, keyword) => `${binding} tem muitos parâmetros. Você pode estar perdendo uma abstração.`,
HasMisspelledBindings: (binding, must, target, keyword) => `${binding} está incorreto. Verifique a ortografia e tente não usar abreviaturas`,
HasMisspelledIdentifiers: (binding, must, target, keyword) => `${binding} está incorreto. Verifique a ortografia e tente não usar abreviaturas`,
Expand Down
1 change: 1 addition & 0 deletions ghcjslib/test/i18n-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('es', () => {
it('HasRedundantBooleanComparison', () => should(mulang.I18n.translate('foo', 'HasRedundantBooleanComparison')).eql('<strong>foo</strong> hace comparaciones booleanas innecesarias'));
it('UsesFail', () => should(mulang.I18n.translate('bar', 'UsesFail')).eql('<strong>bar</strong> usa <i>fail</li>, lo cual es una mala práctica'));
it('HasEmptyIfBranches', () => should(mulang.I18n.translate('foo', 'HasEmptyIfBranches')).eql('<strong>foo</strong> tiene ramas de <i>if</i> vacías'));
it('HasEmptyRepeat', () => should(mulang.I18n.translate('foo', 'HasEmptyRepeat')).eql('<strong>foo</strong> tiene un <i>repeat</i> vacío'));
it('ShouldInvertIfCondition', () => should(mulang.I18n.translate('foo', 'ShouldInvertIfCondition')).eql('<strong>foo</strong> debería invertir la condición del <i>if</i> e intercambiar las ramas'));
it('HasRedundantRepeat', () => should(mulang.I18n.translate('foo', 'HasRedundantRepeat')).eql('<strong>foo</strong> tiene un <i>repeat</i> innecesario'));
it('HasUnreachableCode', () => should(mulang.I18n.translate('foo', 'HasUnreachableCode')).eql('<strong>foo</strong> tiene código inalcanzable'));
Expand Down
23 changes: 14 additions & 9 deletions spec/InspectorSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -382,45 +382,50 @@ spec = do
decontextualize (contextualized (scoped "main") (delegates' anyone)) (
Sequence [
EntryPoint "main" (Application (Reference "m") []),
SimpleProcedure "m" [] None]) `shouldBe` True
SimpleProcedure "m" [] (Return (MuNumber 4))]) `shouldBe` True

describe "delegates" $ do
context "when subroutine is declared" $ do
it "is False when used with a scope" $ do
scoped "main" (delegates anyone) (
Sequence [
EntryPoint "main" (Application (Reference "m") []),
SimpleProcedure "m" [] None]) `shouldBe` False
SimpleProcedure "m" [] (Return (MuNumber 4))]) `shouldBe` False

it "is True on function application in entry point" $ do
delegates (named "m") (Sequence [
EntryPoint "main" (Application (Reference "m") []),
SimpleProcedure "m" [] None]) `shouldBe` True
SimpleProcedure "m" [] (Return (MuNumber 4))]) `shouldBe` True

it "is True on message send application in entry point" $ do
it "is True on message send in entry point" $ do
delegates (named "m") (Sequence [
EntryPoint "main" (Send Self (Reference "m") []),
SimpleMethod "m" [] None]) `shouldBe` True
SimpleMethod "m" [] (Return (MuNumber 4))]) `shouldBe` True

it "is False on message send in entry point to an empty method" $ do
delegates (named "m") (Sequence [
EntryPoint "main" (Send Self (Reference "m") []),
SimpleMethod "m" [] None]) `shouldBe` False

it "is False on direct usage in entry point" $ do
delegates (named "m") (Sequence [
EntryPoint "main" (Reference "m"),
Class "m" Nothing None]) `shouldBe` False
Class "m" Nothing (Return (MuNumber 4))]) `shouldBe` False

it "is False if there is no usage" $ do
delegates (named "m") (Sequence [
EntryPoint "main" (Reference "f"),
SimpleProcedure "m" [] None]) `shouldBe` False
SimpleProcedure "m" [] (Return (MuNumber 4))]) `shouldBe` False

it "is True when delegated and a wildcard is used" $ do
delegates anyone (Sequence [
EntryPoint "main" (Application (Reference "m") []),
SimpleProcedure "m" [] None]) `shouldBe` True
SimpleProcedure "m" [] (Return (MuNumber 4))]) `shouldBe` True

it "is False when not delegated and a wildcard is used" $ do
delegates anyone (Sequence [
EntryPoint "main" (Application (Reference "g") []),
SimpleProcedure "m" [] None]) `shouldBe` False
SimpleProcedure "m" [] (Return (MuNumber 4))]) `shouldBe` False


context "when subroutine is not declared" $ do
Expand Down
Loading