Показать сообщение отдельно
Старый 18.11.2020, 11:28   #5  
Logger is offline
Logger
Участник
Лучший по профессии 2015
Лучший по профессии 2014
 
3,875 / 3123 (112) ++++++++++
Регистрация: 12.10.2004
Адрес: Москва
Записей в блоге: 2
Цитата:
Сообщение от trud Посмотреть сообщение
Даже интерестно, что за страшный метод
Классы коллекций (инициализация, сериализация): List, Set, Map.

Кривой Json на входе валит АОС. Неприятно.

BP проверку написали.
X++:
// pkoz, 21.05.2018
// JEV003427 "Устранение блокировок. Вычистка некорректного кода", PKoz 10.04.2019
// JEV004482 "АХ2012 - Тестирование_Расчеты с клиентами -  Договоры_JEV003679", PKoz 01.03.2020
/*
    This method checks the source text for Mercury rules
*/
protected boolean checkSource_MRC()
{
    xRefTmpReferences thisRefererences;
    DictTable           dictTable;
    boolean ret = true;
    ;

    if (sysBPCheck && sysBPCheck.mustCheckTreeNodeCurLayer_MRC()) // только для кода, написанного на usr слое
    {
        // check if things are used, that mustn't be used directly
        this.initTmpxRefReferences();
        thisRefererences.setTmpData(tmpxRefReferences);

        while select thisRefererences
            where thisRefererences.Kind == xRefKind::ClassStaticMethod
               && thisRefererences.name == staticMethodStr(Global, str2con)
               && thisRefererences.ParentName == classstr(Global)
               && thisRefererences.Reference == XRefReference::Call
        {
            this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                thisRefererences.Line,
                thisRefererences.Column,
                    strfmt("Метод %1%2%3 нужно заменить на Global::%4", // "@SYS55400",
                        thisRefererences.ParentName,
                        (thisRefererences.Kind == xRefKind::ClassInstanceMethod || thisRefererences.Kind == xRefKind::TableInstanceMethod || thisRefererences.Kind == xRefKind::MapInstanceMethod) ? '.' : '::',
                        thisRefererences.Name,
                        staticMethodStr(Global, str2con_ru)
                        ));
        }

        while select thisRefererences
            where thisRefererences.Kind == xRefKind::ClassInstanceMethod
               && thisRefererences.name == MethodStr(DialogBox, new)
               && thisRefererences.ParentName == classstr(DialogBox)
               && thisRefererences.Reference == XRefReference::Call
        {
            if (!strStartsWith(thisRefererences.Path, '\\Classes\\Box\\')) // чтобы не ругалась на сам класс Box
            {
                this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                    thisRefererences.Line,
                    thisRefererences.Column,
                        strfmt("Метод %1%2%3 нужно заменить на вызов соответствующего метода класса %4", // "@SYS55400",
                            thisRefererences.ParentName,
                            (thisRefererences.Kind == xRefKind::ClassInstanceMethod || thisRefererences.Kind == xRefKind::TableInstanceMethod || thisRefererences.Kind == xRefKind::MapInstanceMethod) ? '.' : '::',
                            thisRefererences.Name,
                            ClassStr(Box)
                            ));
            }
        }

        // JEV004482 "АХ2012 - Тестирование_Расчеты с клиентами -  Договоры_JEV003679", PKoz 01.03.2020 -->
        while select thisRefererences
            where thisRefererences.Kind == xRefKind::TableField
               && thisRefererences.name == "RelationType"
               && thisRefererences.Reference == XRefReference::Read
        {
            this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                thisRefererences.Line,
                thisRefererences.Column,
                    strfmt(@"Обращение к полю RelationType нужно заменить на вызов SysDictTable::getConcreteTable(). См. https://dax.axforum.info/forums/showpost.php?p=412653&postcount=11"
                        ));
        }

        while select thisRefererences
            where thisRefererences.Kind == xRefKind::TableField
               && thisRefererences.name == "TableId"
               && thisRefererences.Reference == XRefReference::Read
        {
            if (thisRefererences.ParentName == "Common" ||
                    (thisRefererences.ParentName &&
                     tableName2id(thisRefererences.ParentName)
                    )
               )
            {
                dictTable = new DictTable(tableName2id(thisRefererences.ParentName));
                if (dictTable && dictTable.supportInheritance())
                {
                    this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                        thisRefererences.Line,
                        thisRefererences.Column,
                            strfmt(@"Обращение к полю TableId для таблиц поддерживающих наследование, нужно заменить на вызов SysDictTable::getConcreteTable(). См. https://dax.axforum.info/forums/showpost.php?p=412653&postcount=11"
                                ));
                }
            }
        }
        // JEV004482 "АХ2012 - Тестирование_Расчеты с клиентами -  Договоры_JEV003679", PKoz 01.03.2020 <--

        // JEV005646 "Улучшить стабильность работы тестовой аксапты.", PKoz 16.11.2020 -->
        while select thisRefererences
            where thisRefererences.Kind == xRefKind::ClassStaticMethod
               && thisRefererences.name == staticMethodStr(Map, create)
               && thisRefererences.ParentName == classstr(Map)
               && thisRefererences.Reference == XRefReference::Call
        {
            this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                thisRefererences.Line,
                thisRefererences.Column,
                    strfmt(@"Метод %1%2%3 нужно заменить на Collections_MRC::createMap или Collections_MRC::createMap4Json. См. http://axforum.info/forums/showthread.php?t=27738",
                        thisRefererences.ParentName,
                        (thisRefererences.Kind == xRefKind::ClassInstanceMethod || thisRefererences.Kind == xRefKind::TableInstanceMethod || thisRefererences.Kind == xRefKind::MapInstanceMethod) ? '.' : '::',
                        thisRefererences.Name
                        ));
        }

        while select thisRefererences
            where thisRefererences.Kind == xRefKind::ClassStaticMethod
               && thisRefererences.name == staticMethodStr(List, create)
               && thisRefererences.ParentName == classstr(List)
               && thisRefererences.Reference == XRefReference::Call
        {
            this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                thisRefererences.Line,
                thisRefererences.Column,
                    strfmt(@"Метод %1%2%3 нужно заменить на Collections_MRC::createList или Collections_MRC::createList4Json. См. http://axforum.info/forums/showthread.php?t=27738",
                        thisRefererences.ParentName,
                        (thisRefererences.Kind == xRefKind::ClassInstanceMethod || thisRefererences.Kind == xRefKind::TableInstanceMethod || thisRefererences.Kind == xRefKind::MapInstanceMethod) ? '.' : '::',
                        thisRefererences.Name
                        ));
        }

        while select thisRefererences
            where thisRefererences.Kind == xRefKind::ClassStaticMethod
               && thisRefererences.name == staticMethodStr(Set, create)
               && thisRefererences.ParentName == classstr(Set)
               && thisRefererences.Reference == XRefReference::Call
        {
            this.addSuppressableError(#BPErrorMethodIllegalConstructionUsed,
                thisRefererences.Line,
                thisRefererences.Column,
                    strfmt(@"Метод %1%2%3 нужно заменить на Collections_MRC::createSet. См. http://axforum.info/forums/showthread.php?t=27738",
                        thisRefererences.ParentName,
                        (thisRefererences.Kind == xRefKind::ClassInstanceMethod || thisRefererences.Kind == xRefKind::TableInstanceMethod || thisRefererences.Kind == xRefKind::MapInstanceMethod) ? '.' : '::',
                        thisRefererences.Name
                        ));
        }
        // JEV005646 "Улучшить стабильность работы тестовой аксапты.", PKoz 16.11.2020 <--
    }

    return ret;
}
поставить вызов из
\Classes\SysBPCheckMemberFunction\checkSource